Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 34,258 times

Contents

Related Categories

SocketWrench Control - Initializing the Server

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

  • BLAH

    Posted by millffire on 08 Jan 2005

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

  • help

    Posted by fms on 10 Jul 2003

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