EsUU - ActiveX control

Eurosource, Gruvbyn 415, S-820 50 LOOS, Sweden
( (

Updated: 1999-01-10

EsSock is a control that handle the client aspect of a Internet socket connection. With this control you can connect to a server over the Internet in either Stream or Datagram mode and send/receive data. The interface to the control has been kept simple so that people can program for the Internet with no or little knowledge of the underlying structures.


New features in version 1.1

  1. EsSock can now be used in ASP-applications ( Server side scripting ).



Transfer EsSock32.OCX to your \windows\system or \winnt35\system32 directory and register it by executing the command:

RegSvr32 \Windows\System\EsSock32.OCX

RegSvr32.exe can be found on the Visual Basic 4.0 CD-ROM and in our dll archive ( If RegSvr32.exe fails, it's probably because you don't have the MFC 4.0 DLL library installed on your system. This is available from many sources on the Internet including our ftp archive as MFC40DLL.ZIP. Regsvr32.exe is also included in this archive. If you want to check if you already got the files in they are

  • mfc40.dll
  • msvcrt40.dll
  • oc30.dll
  • olepro32.dll
  • regsvr32.exe

Cookbook or how to use the EsSock Control

The way to work with it

  1. Set type to either Stream (=1) or Datagram (=2). For most of the time you will probably use stream.
  2. Set the address of the server which you want to connect to. Either use the ip-address or the human form "".
  3. Set the Port property for the service you want to connect to.
  4. Use the Connect method. A TRUE response from this method indicated a successful connect.
  5. Use SendString, Send, SendCommand, Read, ReadString to send and receive messages from the host.
  6. Disconnect from the server with the Disconnect method.



String Address

This is the address of the server/host you want to connect to. You can set this value either as an IP-address in the dot notation form as in "" or in the more human readable form as in "".

short ErrorNo

Read only.

When an error is encountered you find a code describing the error here.

Possible errors-codes are:

Symbolic value Description
WSAENETDOWN=10050 The Windows Sockets implementation detected that the network subsystem failed.
WSAEADDRINUSE=10048 The specified address is already in use.
WSAEINPROGRESS=10036 A blocking Windows Sockets call is in progress.
WSAEADDRNOTAVAIL=10049 The specified address is not available from the local machine.
WSAEAFNOSUPPORT=10047 Addresses in the specified family cannot be used with this socket.
WSAECONNREFUSED=10061 The attempt to connect was rejected.
WSAEDESTADDREQ=10039 A destination address is required.
WSAEINVAL=10022 The socket is not already bound to an address.
WSAEISCONN=10056 The socket is already connected.
WSAEMFILE=10024 No more file descriptors are available.
WSAENETUNREACH=10051 The network cannot be reached from this host at this time.
WSAENOBUFS=10055 No buffer space is available. The socket cannot be connected.
WSAENOTSOCK=10038 The descriptor is not a socket.
WSAETIMEDOUT=10060 Attempt to connect timed out without establishing a connection.
WSAEPROTONOSUPPORT =10043 The specified port is not supported.
WSAEPROTOTYPE =10041 The specified port is the wrong type for this socket.
WSAENOTCONN =10057 The socket is not connected.
WSAEMSGSIZE =10040 The datagram was too large to fit into the specified buffer and was truncated.
WSAECONNABORTED=10053 The virtual circuit was aborted due to timeout or other failure.
WSAECONNRESET=10054 The virtual circuit was reset by the remote side.

Short Port

Portnumber for the service you want to connect to. If you have TCP/IP installed on your computer you will find a file called services in the windows directory that contains many of the port numbers that is defined.

long Timeout

This is a time-out used for certain internal calls in EsSock.

short Type

This is an enumerated property that is capable of holding two values. Stream (=1) or Datagram (=2).


BOOL Connect()

Use this method to connect to a service on a remote host. Before you use the method you have to set the Address, Port and possibly also the type property.

You use the Disconnect method to close your connection. Note that some protocols such as SMTP also requires a "quit" command.

Returns TRUE if everything OK and you are connected to the remote host's service.

BOOL Disconnect( )

Disconnects from a remote host.

Returns TRUE if everything OK and you are disconnected from the host..

short Read(LPTSTR buf)

With this command you can read input from an open connection into a buffer. This buffer must be capable of holding at least 512 characters. It is your responsibility to allocate this storage before you call the method.

The number of characters read are returned from the method. If this value is set to null this can indicate that there was no characters to read or that an error occurred. If this happens you should always check the ErrorNo for a possible error code.

As most protocols on the Internet work with text we recommend that you use the ReadString method instead of this one.

BSTR ReadString()

With this command you can read input from an open connection into a string. If an error occurs an empty string is returned and the ErrorNo property is set to the error code for the failure.

BOOL Send( LPCTSTR buf, short count )

Use this method to send count characters from a buffer to the host.

TRUE is returned if everything is OK and FALSE if an error occurred. In case of error the ErrorNo property contains the error code.

BSTR SendCommand( LPCTSTR cmd )

This method can be used to send commands to a server and at the same time fetch the response from the server. Before the string 'cmd' is sent to the server a CRLF pair is added to the tail of the string. This is the most usual way for most Internet protocol's to work.

In case of an error an empty string is returned and you should check the property ErrorNo for the error code if this happens. If ErrorNo is set to zero the server just sent back an empty string.

BOOL SendString( LPCTSTR str )

With this method you can send a string to the host.

TRUE is returned if everything went well and FALSE if an error occured. In case of an error the ErrorNo property contains the error code.


There is no events defined for this component.

Where to get the control?

It is possible that you are reading this documentation without having access to the control itself. If you have Internet access you just need to connect to and fetch a fully working sample of the control. At this location you can also find samples on how to use the control.

We can email the control anywhere in the world if you send us a request to do so. Please state if you want MIME or BINHEX coding. Send request to

If you use the unregistered version of the control a splash screen is displayed from time to time reminding you to register.To get rid of this nag-screen you need to register. Information is available at our site.

We ship anywhere in the world with World-wide First Class/Airmail if you select this option. The only media supported is 3.5" diskettes.The charge for this type of delivery is $15 (USD) extra.


You can get support by sending email to You can also find relevant information on-line at

We also check the newsgroup comp.lang.basic.visual.3rdparty on a regular basis and will try to help on all questions posted there.

How to contact us

  • If you need to contact us the preferred way is through email. Please send a mail to
  • If you want to use phone please call us at +46 657 10620 and Fax: +46 657 10612.
  • If you want to send a snailmail you can send it to
  • Eurosource, Gruvbyn 415A, S-820 50 LOOS, SWEDEN