For PHP and VBSOCKET communication problems, please refer to-php Tutorial

Source: Internet
Author: User
For PHP and VBSOCKET communication problems, please refer to this post, which was last edited by u012436313 at 13:13:58 on



 ';}$ 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 connected now! "End SubPrivate Sub tcpServer_ConnectionRequest (ByVal requestID As Long) If tcpServer. State <> sckClosed Then tcpServer. Close tcpServer. Accept requestID lblstate. Caption =" a client is connected to the local machine! IP: "& tcpServer. remoteHostIPEnd SubPrivate Sub tcpServer_DataArrival (ByVal bytesTotal As Long) Dim strData As String tcpServer. getData strData txtOutput. text = strData & vbCrLf & txtOutput. textEnd SubPrivate Sub txtSendData_KeyPress (KeyAscii As Integer) If KeyAscii = 13 Then If tcpServer. state = sckConnected Then tcpServer. sendData "the server says:" & txtSendData. text txtOutput. text = "server description" & txtSendData. Text & vbCrLf & txtOutput. Text txtSendData. Text = "" Else MsgBox "no connected client currently! "End If End IfEnd Sub






The following error occurs when the PHP page is refreshed normally for the first time but is refreshed for the second time.
Warning: socket_send () [function. socket-send]: unable to write to socket [0]: The address is not provided because the socket is not connected and (when a sendto call is used to send a datagram socket, the request for sending or receiving data is not accepted. In E: \ wamp \ www \ test \ test3.php on line 19




Reply to discussion (solution)

Cancel @ socket_connect @ to check whether warning information exists.

Cancel @ socket_connect @ to check whether warning information exists.

Warning: socket_connect () [function. socket-connect]: unable to connect [0]: unable to connect because the target computer actively rejects the connection. In E: \ wamp \ www \ test \ test3.php on line 14 Warning: socket_send () [function. socket-send]: unable to write to socket [0]: The address is not provided because the socket is not connected and (when a sendto call is used to send a datagram socket, the request for sending or receiving data is not accepted. In E: \ wamp \ www \ test \ test3.php on line 19


It is estimated that it has been connected once.

Y
VB should be able to close the connection. if you don't know VB, check it out.

VB problems. Only one connection is accepted.

VB problems. Only one connection is accepted.

I can use VB to communicate with VB once.

But why does PHP and VB increase connections? Can't I continue sending data based on the original connection?

VB-> VB creat, connect only once
PHP is creat once every refresh, so there are many connections.

VB-> VB creat, connect only once
PHP is creat once every refresh, so there are many connections.

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

I just want to make a function to receive data from the VB client after PHP is sent and save the data to the TXT file.

Everything else is simple. this connection cannot be solved.

You can't refresh the page. if you refresh the page once and wait for a server to execute it again, you should keep a persistent connection in the background.


VB-> VB creat, connect only once
PHP is creat once every refresh, so there are many connections.

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

I just want to make a function to receive data from the VB client after PHP is sent and save the data to the TXT file.

Everything else is simple. this connection cannot be solved.
This is your design architecture. What is the real problem you want to solve? Chat? Office?


VB-> VB creat, connect only once
PHP is creat once every refresh, so there are many connections.

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

I just want to make a function to receive data from the VB client after PHP is sent and save the data to the TXT file.

Everything else is simple. this connection cannot be solved.
Close the connection after receiving VB



VB-> VB creat, connect only once
PHP is creat once every refresh, so there are many connections.

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

I just want to make a function to receive data from the VB client after PHP is sent and save the data to the TXT file.

Everything else is simple. this connection cannot be solved.
Close the connection after receiving VB

Private Sub Form_Load () winsock1.LocalPort = 8888 bytes SubPrivate Sub winsock1_ConnectionRequest (ByVal requestID As Long) If winsock1.State <> sckClosed Then winsock1.Close winsock1.Accept requestID Label1.Caption =! IP: & winsock1.RemoteHostIPEnd SubPrivate Sub winsock1_DataArrival (ByVal bytesTotal As Long) Dim strData As String winsock1.GetData strData Text1.Text = strData winsock1.CloseEnd Sub


I have added but it still does not work.

Look at the VB book by yourself. it seems that you have closed the entire socket. you should just close the connection.
When the socket is closed, bind/accept is disconnected.

Look at the VB book by yourself. it seems that you have closed the entire socket. you should just close the connection.
When the socket is closed, bind/accept is disconnected.

I am also looking for related books today, but I have never found them yet.

Look at the VB book by yourself. it seems that you have closed the entire socket. you should just close the connection.
When the socket is closed, bind/accept is disconnected.

My problem solved

Add a new listener under winsock1.Close and then configure 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.