How can I tell the properties of a socket (which client sent something to a server) 
Author Message
 How can I tell the properties of a socket (which client sent something to a server)

I am trying to make a client/server program where the server waits for a
connection and sends and receives data over the socket.
I am using API calls for this (not a control)

The problem that I have is that the send and receive works fine until
another
client logs on.

When the second client logs on I do not know how to send data to the first
client
because I simply don't know the name/properties of the socket.
and the server only seems to be waiting for data from the 2nd (newest)
client.

Can somebody please tell me how I can see what socket is bound to what
client?
Some userID or something? Or a socket handle?

When there is a connection I now do:

    SocketTwo = accept(SocketOne, SocketPar, Len(SocketPar))

Is it possible to do something like:

    Sock(X) = accept(SocketOne, SocketPar, Len(SocketPar))

So every Sock(X) is a new connection? But then how do I find out the
value of X when a client has sent data?

Another question I have is:
Instead of using the mouse up event in the txtEVENT window:

R = WSAAsyncSelect(Sock, txtEVENT.hwnd, ByVal &H202, ByVal FD_READ)

to see if there is new data, is there some other way to see a client has
sent something? (and act upon it)? Preferable showing which client has sent
it?

Since I am new to winsock could someone please tell me how to do this or
show an example?



Sat, 20 Jul 2002 03:00:00 GMT  
 How can I tell the properties of a socket (which client sent something to a server)
Dan

For your given Port, you should use your first Socket as purely a connection
Socket which accepts a connection from a client. Then redirect the client to
a new Socket specified by the host application for communication between the
given client and your host. Then the client and host should use this Socket
for communication, while the original Socket is still being used as a
'listner'. This means that you can easily monitor the connections to all
clients.

At present it looks like your application will only connect to one client at
a time as you are making only one connection, which you are then
disconnecting when an other machine tries to connect.

Hope this Helps

Wayne Cornish

--

remove [nospam] from e-mail address to reply via mail

Quote:

>I am trying to make a client/server program where the server waits for a
>connection and sends and receives data over the socket.
>I am using API calls for this (not a control)

>The problem that I have is that the send and receive works fine until
>another
>client logs on.

>When the second client logs on I do not know how to send data to the first
>client
>because I simply don't know the name/properties of the socket.
>and the server only seems to be waiting for data from the 2nd (newest)
>client.

>Can somebody please tell me how I can see what socket is bound to what
>client?
>Some userID or something? Or a socket handle?

>When there is a connection I now do:

>    SocketTwo = accept(SocketOne, SocketPar, Len(SocketPar))

>Is it possible to do something like:

>    Sock(X) = accept(SocketOne, SocketPar, Len(SocketPar))

>So every Sock(X) is a new connection? But then how do I find out the
>value of X when a client has sent data?

>Another question I have is:
>Instead of using the mouse up event in the txtEVENT window:

>R = WSAAsyncSelect(Sock, txtEVENT.hwnd, ByVal &H202, ByVal FD_READ)

>to see if there is new data, is there some other way to see a client has
>sent something? (and act upon it)? Preferable showing which client has sent
>it?

>Since I am new to winsock could someone please tell me how to do this or
>show an example?



Tue, 23 Jul 2002 03:00:00 GMT  
 How can I tell the properties of a socket (which client sent something to a server)
Thanks for your reply, I am already using that method but it doesn't work.

I have created a socket which listens for new connections, when a client
connects, a new socket is created (by the accept method), and I start
listening for read or write on that new socket, the first one still waits
for
new connections then.

This method works fine with only one client, you can send and receive
to/from
the server. The problem is that when a 2nd client logs-on, the accept method
starts listening on the new socket again, for read or write events. This
works
as well with only the 2nd client. When the first client sends something the
server
starts receiving from the newest connection, which in this case is the 2nd
client.
So I get an error, because the 2nd didn't send anything.

So I have 2 problems:

1) Is it possible to create sockets using Usersock(1) and Usersock(2) and
Usersock(3). But then how do I know which socket triggered an event.
Because if I wait on those three sockets for read or write events, then
eventually
all 3 sockets would trigger the same event. So how do I find out the value
of X if
I would use Usersock(X) (where X is 1,2,3 etc.) in the event?

2) Is there another way besides wsaasyncselect to see the changes of a
socket?
Something that instead of sending a message to a window would trigger an
event?

Quote:
> For your given Port, you should use your first Socket as purely a
connection
> Socket which accepts a connection from a client. Then redirect the client
to
> a new Socket specified by the host application for communication between
the
> given client and your host. Then the client and host should use this
Socket
> for communication, while the original Socket is still being used as a
> 'listner'. This means that you can easily monitor the connections to all
> clients.

> At present it looks like your application will only connect to one client
at
> a time as you are making only one connection, which you are then
> disconnecting when an other machine tries to connect.

> Hope this Helps

> Wayne Cornish

> --



Tue, 23 Jul 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Sending socket data from VB client to a JAVA based server

2. IIS and ASP session (tell me something)

3. Please tell me I've just missed something

4. Client Socket Responses

5. Server and Client Sockets

6. TCP SOCKETS Server-Client implementation exemple

7. socket access from visual basic client to linux server

8. Change something at the Client Site if a Event arrival in my Webclass

9. Socket-communication between VB Client and AS/400 Server

10. Can I know the address of client socket?

11. Client/Server socket help

12. FTP client control for VB over Win. Sockets

 

 
Powered by phpBB® Forum Software