|
-
Jun 19th, 2001, 05:10 PM
#1
Thread Starter
Addicted Member
Winsock
If I have got an IP address that I want to see is my "server", how can I send a certain bit of data (My IP, then a confirmation message) to the server, and then get the server to recieve it (I need this code as well), before finally (if the server does send a verification message), save that IP to a string?
-
Jun 19th, 2001, 06:04 PM
#2
Lively Member
Check out this Winsock article and maybe you'll get some help there.
-
Jun 20th, 2001, 01:04 AM
#3
Addicted Member
That is a very good article, but if you have any other questions do feel free to post, I (and many others here!) have good experience coding both server and client apps
Things I've Said:
"Life's funny like that...elephants can wear frilly lace panties, and Dubya still looks like a monkey in a big chair"
"Take four goats and strap one to each foot of a llama. Presto, goat-powered llama!"
"You want to get me to work more, get me a Coke. No? Then deal with inferior garbage, I'm not coding another line and your clients can go to......thanks, I'd love a Coke right about now!"
-
Jun 20th, 2001, 08:55 AM
#4
Frenzied Member
If you search the MSDN site, you will find the following description of the error. http://support.microsoft.com/support.../Q183/9/87.ASP
If you followed the example, the problem is most likely due to the socket being closed before the SendData finished its task.
If you want to close the connection after the data has been sent, put the Winsock1.Close in a Winsock1_SendComplete routine.
-
Jun 20th, 2001, 11:07 AM
#5
Addicted Member
Good call, ccoder...I spent a while playing with the example, not seeing adamcox's error...turns out it's a VB5 thing...oh, that crazy Microsoft
Things I've Said:
"Life's funny like that...elephants can wear frilly lace panties, and Dubya still looks like a monkey in a big chair"
"Take four goats and strap one to each foot of a llama. Presto, goat-powered llama!"
"You want to get me to work more, get me a Coke. No? Then deal with inferior garbage, I'm not coding another line and your clients can go to......thanks, I'd love a Coke right about now!"
-
Jun 20th, 2001, 06:02 PM
#6
Frenzied Member
Originally posted by csammis
...turns out it's a VB5 thing...oh, that crazy Microsoft
Do you know for a fact that it is a VB5 thing? I know the MSDN says it applies to V5.0. I've never had the problem 'cause I always keep my connection up until I am ready to terminate the app. Too much overhead to constantly connect, send, recieve and disconnect.
-
Jun 21st, 2001, 12:10 AM
#7
Addicted Member
Well, I tried the example on VBWorld and it worked for me...maybe I'm just lucky!
Things I've Said:
"Life's funny like that...elephants can wear frilly lace panties, and Dubya still looks like a monkey in a big chair"
"Take four goats and strap one to each foot of a llama. Presto, goat-powered llama!"
"You want to get me to work more, get me a Coke. No? Then deal with inferior garbage, I'm not coding another line and your clients can go to......thanks, I'd love a Coke right about now!"
-
Jun 21st, 2001, 03:24 AM
#8
Junior Member
No luck, the tutorial doen't work for me. And i tried it with
VB 6.0. I got the tutorial to work to a certain extend (i can send the message once, when i try to send it a second time, it crashes). I took the link to the messenger program by Evan Christopher Sims, and that does work for, although not stable.
One question concerning this program: what is the best (read quickest) way to use winsock? The program checks every twenty second for changes in status, and it takes a long time to do that. How does icq do that?
NeoMotion
----------------------------
VB 6.0
Almost MCP ;-)
All round nice guy
-
Jun 21st, 2001, 04:06 AM
#9
Addicted Member
If ICQ was written in VB using the Winsock control (dunno that it is), it'd wait for Winsock's many and varied events to fire. Error control, waiting for sends to complete, being alerted when data arrives...it's all good with event-driven programming
Things I've Said:
"Life's funny like that...elephants can wear frilly lace panties, and Dubya still looks like a monkey in a big chair"
"Take four goats and strap one to each foot of a llama. Presto, goat-powered llama!"
"You want to get me to work more, get me a Coke. No? Then deal with inferior garbage, I'm not coding another line and your clients can go to......thanks, I'd love a Coke right about now!"
-
Jun 21st, 2001, 09:24 AM
#10
Frenzied Member
Originally posted by Neomotion
No luck, the tutorial doen't work for me. And i tried it with
VB 6.0. I got the tutorial to work to a certain extend (i can send the message once, when i try to send it a second time, it crashes).
Two questions regarding the client side!
1) are you specifying a LocalPort?
2) are you closing the socket after each send and reopening it?
If yes to both, don't specify a LocalPort. Let the OS assign one for you. The problem has to do with the TIME_WAIT value which allows TCP to ensure that connections are properly closed. The side initiating the close must hang around long enough for the other side to send its final packet.
If you try to reconnect too soon after closing, you will have this problem. By not specifying a port number, the OS will find a port that isn't tied up and assign it.
Another question regarding the server side!
Do you check the socket state for sckClosing (value = 8 indicating that the peer is closing the connection)? When the socket goes to this state, you should close and go back to listening. BTW, this only applies to a server with a single socket control.
-
Jun 22nd, 2001, 12:50 AM
#11
Addicted Member
ccoder, a bit off-topic...but I'd like you to take a look at this thread - http://www.vbforums.com/showthread.p...threadid=84411
It's a ponderance on why the socket layer is the way it is, I'd like your thoughts on the matter since you know your socket stuff
Things I've Said:
"Life's funny like that...elephants can wear frilly lace panties, and Dubya still looks like a monkey in a big chair"
"Take four goats and strap one to each foot of a llama. Presto, goat-powered llama!"
"You want to get me to work more, get me a Coke. No? Then deal with inferior garbage, I'm not coding another line and your clients can go to......thanks, I'd love a Coke right about now!"
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
|