Winsock Woes
Winsock Woes
Winsock Woes
Winsock Woes
Winsock Woes
Winsock Woes Winsock Woes Winsock Woes Winsock Woes Winsock Woes Winsock Woes Winsock Woes Winsock Woes
Winsock Woes Winsock Woes
Winsock Woes
Go Back  Xtreme Visual Basic Talk > > > Winsock Woes


Reply
 
Thread Tools Display Modes
  #1  
Old 11-20-2000, 07:01 AM
Matt Nash
Guest
 
Posts: n/a
Default Winsock Woes


I'm using the winsock control in VB5 to create a Tcp client/server program for sending and recieving data. The problem is, I can't seems to close a connection properly, even if use the .close method. Everytime time I try to reconnect, I get 'Address in Use'. The only way I can get around it is to change the port number of both client and server programs, which is not really feasible at run time. Can anyone tell me what I'm doing wrong, or what I'm not doing that I should do.

Matt

Reply With Quote
  #2  
Old 11-20-2000, 12:00 PM
adebuigny adebuigny is offline
Junior Contributor
 
Join Date: Sep 2000
Location: New Orleans
Posts: 197
Default Re: Winsock Woes

Are you writing both the client and the server? If so, are you closing on both ends? I'm not sure, but it sounds like one of the sides are left hanging upon close.

Reply With Quote
  #3  
Old 11-21-2000, 05:10 AM
Matt Nash
Guest
 
Posts: n/a
Default Re: Winsock Woes

Yeah you were right, I forgot to close one of them. D'oh!!!

I've got another problem though:

I'm sending data from a recordset created on the server side, one field at a time using the prefix DT to determine that the item being sent is data, and putting the data into a listbox on my client machine. The problem is, that as I loop though the fields collection of my recordset, the send the data using <font color=green>winsock.senddata</font color=green>, it seems to group all the data together and send it in one big chunk so it looks like this:

<font color=blue>DTMattDTRobertDTNash etc....</font color=blue>

When I step through the program using f8, I get
<font color=blue>DTMatt
DTRobert
DTNash</font color=blue>
Which is actually what I want.

I've tried sticking a vbCrLf at the end but it still doesn't work. Any ideas people? All, help will be much appreciated.

Matt

Reply With Quote
  #4  
Old 11-21-2000, 10:28 AM
adebuigny adebuigny is offline
Junior Contributor
 
Join Date: Sep 2000
Location: New Orleans
Posts: 197
Default Re: Winsock Woes

Hmmm. Are you grouping the data like this?

string1 = "DTMatt" + vbCrLf
String1 = "DTRobert" + vbCrLf
etc

Winsock.SendData(String1)

Or like this...

String1 = "DTMatt" + vbCrLf
String2 = "DTRobert" + vbCrLf
etc

Winsock.SendData (String1)
Winsock.SendData (String2)

Winsock should be preserving the carriage returns and/or line feeds.

In any case, a better way might be to set up modes of operation. For example. Let say you want to send data. You could do it like this

Winsock.SendData ("--DATAMODE")

This would trigger the reading program to put everything into data (that is until you turn that mode off by setting another mode). Change your modes by putting two dashes (or any other combination of characters you feel would be unlikely to occur in your data) in the data stream. Depending on what mode you are in, your program will react differently.

Check out the SMTP Email program in the examples on this site. It has a good example of using the winsock to communicate with an SMTP Server. That should give you a working example of the methodology I just described.

Hope this helps

Good luck.

Reply With Quote
  #5  
Old 11-22-2000, 03:44 AM
Matt Nash
Guest
 
Posts: n/a
Default Re: Winsock Woes

Thanks a lot for your help.

Matt

Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Winsock Woes
Winsock Woes
Winsock Woes Winsock Woes
Winsock Woes
Winsock Woes
Winsock Woes Winsock Woes Winsock Woes Winsock Woes Winsock Woes Winsock Woes Winsock Woes
Winsock Woes
Winsock Woes
 
Winsock Woes
Winsock Woes
 
-->