Solved

winsock connect-disconnect prob

Posted on 1997-11-28
1
282 Views
Last Modified: 2013-11-13
1. I'm working on a little app, containing a server side and a client side. The clients must be able to connect and disconnect, and connect again.
The first connect works fine, but after disconnecting, a second connect seems impossible, I keep getting the 'adress in use' error on the client side.

to connect I use : tcpclient.connect <hostname> <port>
to disconnect : tcpclient.close

anyone got a clue ?

2. I test this app with two clients on one machine. But it seems that when I let the server send something to all connected clients, it only gets to the last connected client. I read in some news groups that this prob is known, and that it should work fine when using it in a real network setup. Can anyone confirm this ?

Tnx
Christophe VG
0
Comment
Question by:tofke
1 Comment
 
LVL 8

Accepted Solution

by:
mrmick earned 100 total points
ID: 1442784
Bugs, don't ya just hate em?

The workaround:  Use a control array.

On the server side, when you accept a new socket, create a new socket by loading another object instance of the winsock control (Load tcpSocket(Index)) and accepting the connection with it, when it disconnects, you set it to nothing and unload it (Unload tcpSocket(Index)).

On the client side, draw socket1(0) on a form, but don't use it, load socket1(1) and use it til you disconnect, then unload it.  Repeat as necessary!

0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now