Library tutorials & articles
SocketWrench Control
Initializing the Server
The first thing to do is to add a second SocketWrench control to your form, and make it a control array. Initially there will only be one control in the array, identified as Socket2(0). This control will be responsible for listening for client connections. Just as with the client socket control, several of the control's properties should be initialized in the form's Load subroutine. The new subroutine should look like this:
Sub Form_Load ()
Socket1.AddressFamily = AF_INET
Socket1.Protocol = IPPROTO_IP
Socket1.SocketType = SOCK_STREAM
Socket1.Binary = False
Socket1.BufferSize = 1024
Socket1.Blocking = False
Socket2(0).AddressFamily = AF_INET
Socket2(0).Protocol = IPPROTO_IP
Socket2(0).SocketType = SOCK_STREAM
Socket2(0).Blocking = False
Socket2(0).LocalPort = IPPORT_ECHO
Socket2(0).Action = SOCKET_LISTEN
LastSocket = 0
End Sub
The only thing that is new here is the LocalPort property and the NextSocket variable. The LocalPort property is used by server applications to specify the local port that it's listening on for connections. By specifying the standard port used by echo servers, any other system can connect to yours and expect the program to echo back whatever is sent to it.
The LastSocket variable is defined in the "general" section of the Visual Basic application as an integer. It is used to keep track of the next index value that can be used in the control array.
Related articles
Related discussion
-
How to POP3 in C#
by converter2009 (9 replies)
-
Run-time error '91'
by converter2009 (1 replies)
-
VB6 Runtime error 381 subsript out of range Error
by Uncle (2 replies)
-
passing and reading parameters from using Shell
by jigartoliya (0 replies)
-
Convert C++ code to VB6
by mawcot (4 replies)
Related podcasts
-
Listener Feedback 67
This mailbag episode includes FASM, scripts, sockets, SSL/TLS, HTTPS, Windows 7's XP mode, and more. Security Now wiki shownotes For 16kpbs versions, transcripts, and notes (including fixes), visit Steve's site: grc.com, also the home of the best disk maintenance and recovery utility ever written...
I need some help. I want to make the server client program work over the internet, not just a LAN. So my friend can use the client, and I can be the server and we can sedn messages back and forth. Can someone help me with this?
we have established connection between server & client. It works ok when we pass queries from just one form. when we want to load many forms at a time with only a single connection some error has occured. only the first form loads from the database without error when the next form loads there is some error in the connection.
could you help us?
This thread is for discussions of SocketWrench Control.