Tuto WINDEV 25
Part 7: Advanced programming 417 To read and write on the socket, the WINDEV server application must use SocketRead and SocketWrite . Caution : To perform a read operation, a write operation must have been done beforehand. For example: 1. The client computer writes into the socket: it sends a request to the server. 2. The server performs a read operation on the socket in a thread. As soon as a message is received, the message is processed by the server. 3. If a response to the message is required, the server identifies the client computer ( SocketClientInfo ) and sends a response to it. Closing the socket To end the communication, the server can close the socket with SocketClose . Remark : the socket can also be closed by the client computer. Client application A client application of a socket server connects to a standard server in order to exchange information via socket. Example: A client WINDEV application can connect to a standard news server on Internet. The steps for creating a client application are as follows: 1. Connecting to the server. 2. Exchanging data. 3. Ending the communication. Connecting to the server To connect to a server socket, all you have to do is use SocketConnect . This function is used to perform a request for connecting to the server. The socket is identified by its port and by its address. Exchanging data When two computers are using the same socket, a communication stream is established between these two computers. These two computers can read and write character strings on the socket. Remark : To avoid locking the applications, the management of incoming messages is often performed by a specific thread. To read and write on the socket, the WINDEV client application must use SocketRead and SocketWrite . Ending the communication To end the communication, all you have to do is close the socket from the client computer with SocketClose . Remark : you also have the ability to end the communication from the server.
Made with FlippingBook
RkJQdWJsaXNoZXIy NDQ0OA==