Winsock Combining Strings
Winsock Combining Strings
Winsock Combining Strings
Winsock Combining Strings
Winsock Combining Strings
Winsock Combining Strings Winsock Combining Strings Winsock Combining Strings Winsock Combining Strings Winsock Combining Strings Winsock Combining Strings Winsock Combining Strings Winsock Combining Strings
Winsock Combining Strings Winsock Combining Strings
Winsock Combining Strings
Go Back  Xtreme Visual Basic Talk > > > Winsock Combining Strings


Reply
 
Thread Tools Display Modes
  #1  
Old 06-22-2006, 08:49 PM
KylelLeonard KylelLeonard is offline
Newcomer
 
Join Date: Sep 2005
Posts: 9
Default Winsock Combining Strings


Winsock seems to be combining strings when i run the following code...

Code:
Dim i As Integer, AccountData As String, o As Integer
For o = 0 To frmServer.Winsock.UBound
    If frmServer.Winsock(o).State = 7 Then
        For i = 1 To 199
            If Account(i).Name <> "" Then
                AccountData = "0./.updatechars." & Account(i).Name & "." & Account(i).charXpos & "." & Account(i).charYpos
                Call frmServer.Winsock(o).SendData(AccountData)
                Exit For
                frmServer.txtLogConnections.Text = frmServer.txtLogConnections.Text & "NotExiting" & vbCrLf
            End If
        Next i
    End If
Next o
I'm not sure if its sending the data too fast(as this is on the same computer) and the other winsock is picking it up as a single packet or what is actualy happening. If anyone could send some possible ideas as to what the problem is or any ideas of whats going on that would be really appreciated.

Thanks, Kyle
Reply With Quote
  #2  
Old 06-22-2006, 10:06 PM
dilettante's Avatar
dilettanteWinsock Combining Strings dilettante is offline
Underclocked lifestyle

Forum Leader
* Guru *
 
Join Date: Feb 2005
Location: Michigan, USA
Posts: 4,529
Default

You have fallen prey to The Packet Fallacy.

Winsock Programmer's FAQ - The Lame List
Quote:
20. Assuming stream sockets maintain message frame boundaries. Mind bogglingly lame.

Reason: Stream sockets (TCP) are called stream sockets, because they provide data streams (duh). As such, the largest message size an application can ever depend on is one-byte in length. No more, no less. This means that with any call to send() or recv(), the Winsock implementation may transfer any number of bytes less than the buffer length specified.

Alternative: Whether you use a blocking or non-blocking socket, on success you should always compare the return from send() or recv() with the value you expected. If it is less than you expected, you need to adjust the buffer length, and pointer, for another function call (which may occur asynchronously, if you are using asynchronous operation mode).
What this is trying to tell you is that a TCP socket has no "packets" - it's a stream protocol. You must impose a record (or message) structure on it with some sort of in-line framing, and properly buffer received data until you encounter complete frames of data to process.


Maybe look at the attached sample code?
Attached Files
File Type: zip SimpleChat.zip (14.0 KB, 12 views)
Reply With Quote
  #3  
Old 06-22-2006, 10:17 PM
KylelLeonard KylelLeonard is offline
Newcomer
 
Join Date: Sep 2005
Posts: 9
Default

Oh, God this seems to be complicating a complicated mess just a little more . I'll look at the source you posted and see if i can work this out, thanks for the help.
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 Combining Strings
Winsock Combining Strings
Winsock Combining Strings Winsock Combining Strings
Winsock Combining Strings
Winsock Combining Strings
Winsock Combining Strings Winsock Combining Strings Winsock Combining Strings Winsock Combining Strings Winsock Combining Strings Winsock Combining Strings Winsock Combining Strings
Winsock Combining Strings
Winsock Combining Strings
 
Winsock Combining Strings
Winsock Combining Strings
 
-->