473,416 Members | 1,731 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Async TCP Sockets

mak
Dear Friends,

I'm working on real time stock quotes display. Using Async tcp sockets
in .net csharp. Client software running perfect on LAN and ISDN but not
good on ip dialup. After lot of testing i found the result is, I'm
sending packet by packet data to client socket but client receiving
stream read all packets at once.

Can i reduce the tcp window size in .net or any method i can use to
bound client get packet by packet data.

Please reply, its urgent I really appreciate.

Thanks,

-mak

Nov 17 '05 #1
5 2938
You can not control the packets sent over the network, think in terms of
streams. So, this is a typical boundary problem of sockets. There are 3
solutions to this problem:

1) Use packets of fixed size
2) Include the (variable) size in each packet
3) Use a delimiter to separate packets

With any of those approaches the receiver will know to separate the messages
from the stream.

Details and samples are provided in the following book:

C# Network Programming
http://www.amazon.com/exec/obidos/tg...40812?v=glance

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

"mak" <mo********@hotmail.com> escribió en el mensaje
news:11**********************@g47g2000cwa.googlegr oups.com...
Dear Friends,

I'm working on real time stock quotes display. Using Async tcp sockets
in .net csharp. Client software running perfect on LAN and ISDN but not
good on ip dialup. After lot of testing i found the result is, I'm
sending packet by packet data to client socket but client receiving
stream read all packets at once.

Can i reduce the tcp window size in .net or any method i can use to
bound client get packet by packet data.

Please reply, its urgent I really appreciate.

Thanks,

-mak

Nov 17 '05 #2
Hi all,

I am also facing the same problem as stated by Mak, and I have
implemented Carlos's suggestion.

But the problem is the number of bytes received by the asynchronous
socket is not exact multiple of the piecesize as I had anticipated.

For example-
lets assume the piece size is 8000Bytes.
But the listener socket data receives any amount of data from 0 to the
buffer size it is provided with.My buffer size for the testing case
was 33000Bytes.
And the data it received was like-25876 Bytes,26420 Bytes,sometimes
33000bytes.

I am at the end of my wits what is happening here.

Any kind of help will be deeply appreciated.

Thank you all.

Nov 17 '05 #3
Sorry not to mention it in my previous post:

As the number of bytes received is not exact multiple of (piecesize +
delimiter) how am I going to know what the bytes received contains and
what to do with it.

to make it a bit clear what is happening is:

pppp:for a piece, dd for a delimiter, so ppppdd makes one piece.

but what i get at the listener end issomething like ppppddppppddpp or
something like it. So at the end I dont know how to deal with the
fractured pieces at the end and also the fractured piece that will be
received next at the listener.

Thanks.

Nov 17 '05 #4
"just_starting" <ju***********@gmail.com> wrote in news:1121351626.287858.266720
@o13g2000cwo.googlegroups.com:
But the problem is the number of bytes received by the asynchronous
socket is not exact multiple of the piecesize as I had anticipated.
And it never will be - thats how sockets work, and in fact most network transports.
And the data it received was like-25876 Bytes,26420 Bytes,sometimes
33000bytes.

I am at the end of my wits what is happening here.


You will receive whatever the network happens to see at that time. You have to reassemble it.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Develop ASP.NET applications easier and in less time:
http://www.atozed.com/IntraWeb/
Nov 17 '05 #5
at
It is streaming, dude, the implication is you don't know how much a get
receives. It is your own protocol that makes sense of the stream of bytes so
you need to buffer, determine begin and end and then do whatever you want to
do with it.

"just_starting" <ju***********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Sorry not to mention it in my previous post:

As the number of bytes received is not exact multiple of (piecesize +
delimiter) how am I going to know what the bytes received contains and
what to do with it.

to make it a bit clear what is happening is:

pppp:for a piece, dd for a delimiter, so ppppdd makes one piece.

but what i get at the listener end issomething like ppppddppppddpp or
something like it. So at the end I dont know how to deal with the
fractured pieces at the end and also the fractured piece that will be
received next at the listener.

Thanks.

Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ben | last post by:
I've written a fair amount of sockets code using the Winsock2 API, but I am having some trouble converting to the .Net Sockets API, specifically asynchronous sockets. What I have is a form that is...
3
by: David | last post by:
Hi, Ive been trying to work this out for the past 2 days now and im not getting anywhere fast. The problem i have is that i am using Asynchronous sockets to create a Socket Client library....
1
by: Trevor | last post by:
Does the async. sockets implementation in .NET use IO Completion Ports (IOCP) internally or would I have to use P/Invoke to use IOCP in a C# async. socket server?
0
by: whizpop | last post by:
Hi, First of all, thanks for a great starter kit, now If I could just get it to work (fully). I am trying to compile and run the solution/services all on a local dev box. I am able to...
8
by: Dinsdale | last post by:
I am trying to write a Tcp "Server" that opens a class that wraps a tcp socket when a new connection is made (Listener.AcceptSocket()). Everything is going swimmingly except when I try to close the...
4
by: Greg Young | last post by:
Ok so I think everyone can agree that creating buffers on the fly in an async socket server is bad ... there is alot of literature available on the problems this will cause with the heap. I am...
4
by: nyhetsgrupper | last post by:
Hi, I've written a async server app. This app start by connecting to a client and then send some data (BeginSend). When the data is sent, the server is starting to listen for incomming data....
4
by: nyhetsgrupper | last post by:
I'm writing a server application connection to multiple clients using sockets. I want one socket for each client, and the comunication needs to be async. I could use the async sockets methods...
11
by: atlaste | last post by:
Hi, In an attempt to create a full-blown webcrawler I've found myself writing a wrapper around the Socket class in an attempt to make it completely async, supporting timeouts and some scheduling...
1
by: Ryan Liu | last post by:
Hi, I have a 100 clients/ one server application, use ugly one thread pre client approach. And both side user sync I/O. I frequently see the error on server side(client side code is same, but...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.