Solved

sending long data through winsock

Posted on 2004-08-02
7
171 Views
Last Modified: 2013-11-13
I want my program to be able to send long data through winsock in packets of 3000 bytes.
My code is constructed of:

strData - Date to send through winsock

If Len(strData) > "4000" Then
split the data here so it sends 4000 bytes then it checks again to see if its over 4000 and so on. therefore a loop will be added...


What is the code to tell use that the winsock is finished sending the first packet so we can move onto the next?
Thank you for your time
0
Comment
Question by:doyledom
  • 2
7 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 75 total points
ID: 11694552
You can send a packet size field before your actual data, so your receiving function reads it first and prepare to read sized data.
0
 
LVL 52

Assisted Solution

by:Carl Tawn
Carl Tawn earned 75 total points
ID: 11695900
The other method is to attach a special character or sequence of characters to the end of each packet to indicate that more is coming.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 11697936
If I remember correctly there's no guarantee of the order in which packets will be delivered.  You might need to send a packet telling the distant end to expect x number of additional packets and then have it send a reply back acknowledging that before you begin sending the real data packets.  Just a thought.  I haven't used Winsock a lot, but enough to know that it doesn't always behave as you might expect.
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 11697980
>If I remember correctly there's no guarantee of the order in which packets will be delivered.
This is in case of using UDP frames (author has not specified frame type)

0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question