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.

Comments

  1. 08 Jan 2005 at 15:46

    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?

  2. 10 Jul 2003 at 01:43

                    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?
                                 

  3. 01 Jan 1999 at 00:00

    This thread is for discussions of SocketWrench Control.

Leave a comment

Sign in or Join us (it's free).

Catalyst Development

Related discussion

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...

We'd love to hear what you think! Submit ideas or give us feedback