|
-
Client server communication with Winsock
Dear all,
I am building a client server application using Winsock control.
Based on that I have the following code part on server side which try to
connect to the first based port and if not scan to the next free on on a
range of 10:
For iPortNumber = ServerInfo.ListenPort To ServerInfo.ListenPort + 10
DoEvents
tcp.LocalPort = iPortNumber
On Error Resume Next
tcp.Listen ' If we get an error, the port is busy.
If Err.Number = 10048 Then ' port is busy
Else
ServerInfo.ListenPort = iPortNumber
ServerInfo.bRunning = True
Exit Function
End If
tcp.Close
Next iPortNumber
What happen next is that the client side application need to know what is
the communication port that has been selected by the server.
Is there a way that the server informed about the client about that port
number ?
For the client side, it used the based port number but as the server has
notify that it was used then the client point to the wrong port tio initiate
a communication.
Thansk for your help
Regards
CALDERARA Serge
Maillefer S:A
-
Re: Client server communication with Winsock
with the messenger I'm making, I use port 1169 for all the connections. I
made an aray of winsock controls. when a connection is requested, I accept
it, then make the next control listen. then I have an integer aray to keep
track of what controls are being used. 0 for open, 1 for listening, and 2
for connected. when a connection is closed, it checks to make sure there
is a control listening.
Matthew Kemmerer
Mattsoft.net
"Calderara Serge" <serge.calderara@maillefer.net> wrote:
>
>Dear all,
>
>I am building a client server application using Winsock control.
>Based on that I have the following code part on server side which try to
>connect to the first based port and if not scan to the next free on on a
>range of 10:
>
>For iPortNumber = ServerInfo.ListenPort To ServerInfo.ListenPort + 10
> DoEvents
> tcp.LocalPort = iPortNumber
> On Error Resume Next
> tcp.Listen ' If we get an error, the port is busy.
> If Err.Number = 10048 Then ' port is busy
> Else
> ServerInfo.ListenPort = iPortNumber
> ServerInfo.bRunning = True
> Exit Function
> End If
>
> tcp.Close
>Next iPortNumber
>
>What happen next is that the client side application need to know what is
>the communication port that has been selected by the server.
>
>Is there a way that the server informed about the client about that port
>number ?
>
>For the client side, it used the based port number but as the server has
>notify that it was used then the client point to the wrong port tio initiate
>a communication.
>
>Thansk for your help
>Regards
>
>CALDERARA Serge
>Maillefer S:A
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks