Library tutorials & articles
A TCP/IP socket server object for Visual Basic
By Len Holgate, published on 15 Aug 2002
Wrap up
Note that because the socket server uses IO Completion Ports it will only work on Windows NT/2000/XP. Windows 9x is not supported.
The following source was built using Visual Studio 6.0 SP5 and Visual Studio .Net. You need to have a version of the Microsoft Platform SDK installed
All of the zip files mentioned can be found in the single zip file attached to this article.
- COMSocketServer.dll - The socket server COM object
- COMSocketServer2.zip - The source code to the above COM object
- COMSocketServerClient.zip
COMSocketServerClient.zip - a VB echo server
- 11th June 2002 - Initial revision.
- 18th June 2002 - Removed call to ReuseAddress() during the creation of the listening socket as it not required - Thanks to Alun Jones for pointing this out to me.
Related articles
Related discussion
-
How to POP3 in C#
by converter2009 (9 replies)
-
Flex 3 Component Solutions: Build Amazing Interfaces with Flex Components
by matquy_kyo22 (0 replies)
-
Java - Closing inputstream causes socket to close
by led1433 (1 replies)
-
The "Easy Installer" from JoomlaTag
by msecure32 (0 replies)
Related podcasts
-
Java Posse #206 - Newscast for Sept 17th 2008
Newscast for Sept 17th 2008Fully formatted shownotes can always be found at http://javaposse.com Java complexity again, but from a different angle:http://forums.java.net/jive/thread.jspa?messageID=298125&tstart=0#298125 JVM Language summit - the details emergehttp://openjdk.java.net/project...
I ran the server on one machine and the client on another and managed to get a connection and send some data. However after sending a few test messages "1234567890" I try and receive as string at the other end and it stops working. I put in extra calls in the event handlers and they don't get called. The sender thingks it has sent the data. The only way I can stop it is to open the connection again and then press send. Any ideas?
Also when I close down the server, Windows2000 server won't let me delete the file even though it is not in the process list - is there some resource that needs closing in the code somewhere on exit?
I am trying to get a reliable point to point comms for sending some string data.
Ross D.
There was a stupid precedence error in the original code, this may be related to it?
LPOLESTR pOle = ((lpa = (char*)mpData) == NULL) ? NULL : ATLA2WHELPER((LPWSTR) alloca(mlength + 1*2), _lpa, mlength);
should be
LPOLESTR pOle = ((lpa = (char*)mpData) == NULL) ? NULL : ATLA2WHELPER((LPWSTR) alloca((mlength + 1)*2), _lpa, mlength);
I'm afraid I don't have a free version of this code that includes client support.
Yes.
may I use this library for a client application? do you have another dll to do this (with vb6)? great job
There're several useful Winsock tutorial on this site... But its not detailing enough considerations in helping newbie extend the tutorial into actual application environment. One of them is providing a tutorial on preventing reentrancy when working high socket traffic scenario.
Typical Winsock application logic when data arrives...
1. The Winsock_DataArrival event fires when client sockets send data to the listening socket server
2. On Data Arrival, Inspect the data received
3. Process the data received (e.g. Lookup Databases, Refresh GUI, and others)
When multiple data stream or even large chunk of data arrive while your code is Processing "time-instensive" routines/tasks will require u to implement a FIFO buffer into your code to ensure all incoming data are captured and processed properly... I'm pleading for the community to add this logic to existing tutorial or post some sample code. Thanks in advance.
Does you server support multiple clients connecting simultaneously?
This thread is for discussions of A TCP/IP socket server object for Visual Basic.