|
-
Jan 31st, 2001, 03:17 AM
#1
Thread Starter
Hyperactive Member
Can someone enlighten me on how, when using the winsock api, you are notified when you have incoming data (i.e. when you're listening) ?
td.
"One logical slip and an entire scientific edifice comes tumbling down." - Robert M. Pirsig
[email protected]
"but if Einstein is right and God is in the details, reality requires that we sometimes get religion." - Scott Meyers.
-
Feb 1st, 2001, 01:47 AM
#2
Thread Starter
Hyperactive Member
umm...
Ok, maybe i wasn't specific enough. I want to know how, when you using the Winsock API Listen method, how the data arrival/ connection requested events (etc) are reflected.
Cheers.
td.
"One logical slip and an entire scientific edifice comes tumbling down." - Robert M. Pirsig
[email protected]
"but if Einstein is right and God is in the details, reality requires that we sometimes get religion." - Scott Meyers.
-
Feb 3rd, 2001, 03:08 AM
#3
Thread Starter
Hyperactive Member
"One logical slip and an entire scientific edifice comes tumbling down." - Robert M. Pirsig
[email protected]
"but if Einstein is right and God is in the details, reality requires that we sometimes get religion." - Scott Meyers.
-
Feb 3rd, 2001, 04:13 AM
#4
There is a Winsock API example here. It downloads a page from a HTTP server. Or in short, the Winsock API does not seem to be event driven. Rather,
Code:
' Make the socket non-blocking, so calls to recv don't halt the program waiting for input.
retval = ioctlsocket(sock, FIONBIO, 1)
' Read the response from the other system. A more sophisticated program
' would watch to see if the connection ever times out (i.e., if the connection is
' lost). For brevity, such code is omitted here.
Do
buffer = Space(4096)
retval = recv(sock, ByVal buffer, Len(buffer), 0)
If retval <> 0 And retval <> SOCKET_ERROR Then
reply = reply & Left(buffer, retval)
End If
' Process background events so the program doesn't appear to freeze.
DoEvents
Loop Until retval = 0
The above code is from the page at vbapi.com in the link above.
-
Feb 3rd, 2001, 04:40 AM
#5
Thread Starter
Hyperactive Member
For a client, this is fine. I need the process for a Server. It has to listen for new connections etc. How are incoming connections/requests reflected the the server proggy?
td.
"One logical slip and an entire scientific edifice comes tumbling down." - Robert M. Pirsig
[email protected]
"but if Einstein is right and God is in the details, reality requires that we sometimes get religion." - Scott Meyers.
-
Feb 3rd, 2001, 07:40 AM
#6
If you know C literate people, you might want them to translate the listen and accept page at MSDN for you cause it sure beats me!
-
Feb 12th, 2001, 06:34 PM
#7
is this what you want?
If you want to know how to use the DataArrival and ConnectionRequest events, here ya go. I didn't really understand what you were asking
tumblingdown
Private Sub WinSockServer_DataArrival(ByVal bytesTotal As Long)
On Error Resume Next
Dim cString As String
WinSockServer.GetData cString 'Assign incoming data to cString
'Process data in cString example
If Left(cString, 6) = "MsgBox" Then
MsgBox Mid(cString, 6)
End If
End Sub
Private Sub WinSockServer_ConnectionRequest(ByVal requestID As Long)
WinSockServer.Accept requestID
End Sub
-
Feb 13th, 2001, 03:00 AM
#8
Thread Starter
Hyperactive Member
Please. Read my question. I am not using a Control. I wish to do this using the API. Let me phrase the question another way.
How do you make an object from an external lib (in this case winsock) hook to your (vb's) Event Sink?
td.
(i suspect it cannot be done)
"One logical slip and an entire scientific edifice comes tumbling down." - Robert M. Pirsig
[email protected]
"but if Einstein is right and God is in the details, reality requires that we sometimes get religion." - Scott Meyers.
-
Feb 13th, 2001, 02:45 PM
#9
maybe it can be
Maybe you can. I havn't tried this, but it sounds logical.
When I run around the internet, I sometimes use several IE windows to access two different accounts on the same server. This doesn't work if the server used cookies to transfer information, but it does in other cases.
How can I do that? The server is seeing my ip address and two different port numbers. That is how I suspect it tells the difference. If I'm right you could therefore use the API to listen and send messages on the same port and you would be fine. If you listen on port 12345, you have to send data on port 12345.
-
Feb 14th, 2001, 02:19 AM
#10
Thread Starter
Hyperactive Member
Pardon? Sorry, i don't see the relevance to the question.
td.
"One logical slip and an entire scientific edifice comes tumbling down." - Robert M. Pirsig
[email protected]
"but if Einstein is right and God is in the details, reality requires that we sometimes get religion." - Scott Meyers.
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
|
Click Here to Expand Forum to Full Width
|