& lt; ? PHP
='127.0.0.1' $server;
$port=8888;
$sockets=socket_create (AF_INET SOCK_STREAM, SOL_TCP);
If ($socket & lt; 0 {
Echo socket_strerror ($socket);
} else {
Echo 'success & lt; Br/& gt; ';
}
$result=@ socket_connect ($sockets, $server, $port);
$buf='hello I'
$len=strlen ($buf);
Socket_send ($sockets, $buf, $len, 0).
Socket_close ($socket);
?>
Option Explicit
Private Sub Form_Load ()
TcpServer. LocalPort=8888
TcpServer. Listen
Lblstate. Caption="there is no client connected!"
End Sub
Private Sub tcpServer_ConnectionRequest (ByVal requestID As Long)
If tcpServer. State & lt;> SckClosed Then tcpServer. Close
TcpServer. Accept requestID
Lblstate. Caption="have the client connected to the machine! IP: "& amp; TcpServer. RemoteHostIP
End Sub
Private Sub tcpServer_DataArrival (ByVal bytesTotal As Long)
Dim strData As String
TcpServer. GetData strData
TxtOutput. Text=strData & amp; VbCrLf & amp; TxtOutput. Text
End Sub
Private Sub txtSendData_KeyPress (KeyAscii As Integer)
If KeyAscii=13 Then
If tcpServer. State=sckConnected Then
TcpServer. SendData publishes the event "server said:" & amp; TxtSendData. Text
Said txtOutput. Text="server" & amp; TxtSendData. Text & amp; VbCrLf & amp; TxtOutput. Text
TxtSendData. Text=""
The Else
MsgBox "there is no connection client!"
End the If
End the If
End Sub
normal but the second time for the first time when the refresh PHP page to the following error
Warning: socket_send () function. The socket - send] : unable to write to the socket [0] : because the socket is not connected and (when using a sendto call send a datagram socket) does not provide the address, send or receive data request is not accepted, in E: \ \ wamp \ WWW \ test \ test3 PHP on line 19
VB sometimes appear such mistakes
CodePudding user response:
Obviously, the service of your code can only support a client connection at once, so inevitable that as a result, suggest you still find another a Winsock multi-client communication examples and have a look, not a two words can explain clearly,CodePudding user response:
I think, should be your PHP refreshed, it is the first connection is broken, to create a connection,And your VB program there, only support a connection;
PHP to refresh the connection disconnected, your tcpServer doesn't disconnect (VB end should be not notified), so you can't accept the new connection request,
CodePudding user response: