Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

winsock connect-disconnect prob

Posted on 1997-11-28
1
Medium Priority
?
296 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 400 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
Suggested Courses

783 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