PHP and VB SOCKET communication problems please look at the

Source: Internet
Author: User
This post was last edited by u012436313 on 2013-10-14 13:13:58



 
  ';} $result = @socket_connect ($socket, $server, $port); $buf = ' Hello me '; $len = strlen ($BUF); Socket_send ($socket, $buf, $len, 0); Socket_close ($socket);? >


Option explicitprivate Sub Form_Load ()    tcpserver.localport = 8888    tcpserver.listen    lblstate. Caption = "No client is currently connected!" "End subprivate Sub tcpserver_connectionrequest (ByVal RequestID as Long)    If tcpserver.state <> sckclosed then T Cpserver.close    tcpserver.accept RequestID    lblstate. Caption = "There are clients connected to this machine!" IP: "& Tcpserver.remotehostipend subprivate Sub tcpserver_dataarrival (ByVal bytestotal as Long)    Dim strdata as St Ring    tcpserver.getdata strdata    txtoutput.text = strdata & vbCrLf & Txtoutput.textend subprivate Sub Txtsenddata_keypress (KeyAscii as Integer)    if KeyAscii =        if tcpserver.state = sckconnected            Then Tcpserver.senddata "Server said:" & txtsenddata.text            txtoutput.text = "Server said" & Txtsenddata.text & VbCrLf & Txtoutput.text            txtsenddata.text = "        Else            MsgBox" is currently not connected to the client! "        End If    End IfEnd Sub






The first time normal but the second time to refresh the PHP page, the following error occurs
Warning:socket_send () [Function.socket-send]: Unable to write to socket [0]: No address is provided because the socket is not connected and (when sending a datagram socket using a sendto call) , the request to send or receive data was not accepted. In E:\wamp\www\test\test3.php on line 19




Reply to discussion (solution)

Cancel the @socket_connect @ see if there is a warning message

Cancel the @socket_connect @ see if there is a warning message

Warning:socket_connect () [Function.socket-connect]: Unable to connect [0]: Unable to connect because the target computer is actively rejecting. In E:\wamp\www\test\test3.php on line 14warning:socket_send () [Function.socket-send]: Unable to write to socket [0]: Due to socket The word is not connected and (when sending a datagram socket using a sendto call) No address is provided, and the request to send or receive data is not accepted. In E:\wamp\www\test\test3.php on line 19


I think it's been connected once.

Y
VB there should be close connection action, do not understand VB, you see

VB side of the problem. He only accepts one connection.

VB side of the problem. He only accepts one connection.

I use VB and VB Time Communication connection once can

But why does the communication with PHP and VB increase the connection? Can not continue to send data on the basis of the original connection

Vb->vb creat, connect only once
PHP is creat once per refresh, so it's a lot of connections

Vb->vb creat, connect only once
PHP is creat once per refresh, so it's a lot of connections

Alas, I don't know how to solve this problem.

I just want to do a function PHP send after the client side of VB to receive data and save the data in TXT

The rest is simple, and this connection is not a problem.

Refresh Page No, you refresh once, wait a server to re-execute, should be in the background to maintain long-connected


Vb->vb creat, connect only once
PHP is creat once per refresh, so it's a lot of connections

Alas, I don't know how to solve this problem.

I just want to do a function PHP send after the client side of VB to receive data and save the data in TXT

The rest is simple, and this connection is not a problem.
This is the architecture of your design. What is the real problem you want to solve? Chat? Office?


Vb->vb creat, connect only once
PHP is creat once per refresh, so it's a lot of connections

Alas, I don't know how to solve this problem.

I just want to do a function PHP send after the client side of VB to receive data and save the data in TXT

The rest is simple, and this connection is not a problem.
VB after receiving the close connection



Vb->vb creat, connect only once
PHP is creat once per refresh, so it's a lot of connections

Alas, I don't know how to solve this problem.

I just want to do a function PHP send after the client side of VB to receive data and save the data in TXT

The rest is simple, and this connection is not a problem.
VB after receiving the close connection

Private Sub Form_Load ()    Winsock1. LocalPort = 8888    Winsock1. Listenend subprivate Sub winsock1_connectionrequest (ByVal RequestID as Long)    If Winsock1. State <> sckclosed then Winsock1. Close        Winsock1. Accept RequestID        Label1.Caption = "There is a client access to this machine!" IP: For "& Winsock1. Remotehostipend subprivate Sub winsock1_dataarrival (ByVal bytestotal as Long)    Dim strdata as String    Winsock1. GetData strdata    text1.text = strdata    winsock1. CloseEnd Sub


I've already added it, but I still can't.

Read the VB book yourself, feel that you are close the entire socket, should just close the connection
The socket is closed, even the bind/accept are dead.

Read the VB book yourself, feel that you are close the entire socket, should just close the connection
The socket is closed, even the bind/accept are dead.

I've been looking for books today, but I haven't found them.

Read the VB book yourself, feel that you are close the entire socket, should just close the connection
The socket is closed, even the bind/accept are dead.

My problem is solved.

In Winsock1. Close below add a  re-listen on the line Winsock1. Listen
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.