Jump to content
Sign in to follow this  
tammelinn

TCP packet problems

Recommended Posts

tammelinn

I've been trying to teach myself about TCP by writing a simple server/client application. The working code is at the bottom of the post.

The client "logs in" to the server, the server replies, and then the client sends ten numbers to the server. The server displays all its messages in a GUI window.

Now I need a little advice about the next step. The server checks for messages once every 2 seconds; the client sends one about once every 3-5 seconds. Because the client's loop is longer, the server never receives more than one message at a time.

Here is my question. If I want to send several pieces of information from the client to the server at the same time - in other words, if I want to replace these lines...

For $a = 1 to 10
    Sleep(Random(3000, 5000))
    TCPSend($Socket, TimerDiff($timestamp))
NextoÝ÷ Û­Ø^±æ®¶­sdf÷"b33c¶ÒFò 6ÆVW&æFöÒ3ÂS¢D56VæBb33c·6ö6¶WBÂgV÷C´W&R2FRæWBÖW76vRgV÷C² D56VæBb33c·6ö6¶WBÂFÖW$Ffbb33c·FÖW7F×¢D56VæBb33c·6ö6¶WBÂgV÷C´v÷BFCògV÷C²¤æWoÝ÷ ÛZ¶+-騲×~'"z{pk+hëmë®÷«¶Þqè¯zØkyçb²Ø§rÙ²Æ zƧvz-¢w¥¢x j¶åyÚ'xa¢è!µ¦èºÛاÞë,j®­ç%éíjÖ­g×rbìاú+j·©'ë¢kazÇ«½êÈj[(.Zn­±éÝx²Úâ   bꮢÑޭ謶¦zËî7ã~¢ÛajÚ®¢Ö§v¯zØ^±êïz»)+)í¢Økyë-®)à°÷«ªl¶«{lj·¬jezÊ%ºØ¨ØZ·¥«è×¢¶«êÞËazaz¼"±çîËb¢v¥r^mCÃ17Ý8^±êïz·b²ZÊÈ^ƶ­êíéâ× z»'£-Á«0¢¹"â槫j
?m«­¢+ØìMIYH((¥¹±Õ±Ðí5¥Í¹ÔÌÐì(¥¹±Õ±ÐíU%
½¹ÍѹÑ̹ÔÌÐì(¥¹±Õ±ÐíѹÔÌÐì(¥¹±Õ±ÐíÕ¥¥Ð¹ÔÌÐì(¥¹±Õ±ÐíÍÑÉ¥¹¹ÔÌÐì()!½Ñ­åMÐ ÅÕ½ÐííÉôÅÕ½Ðì°ÅÕ½ÐíQɵ¥¹ÑMÉ¥ÁÐÅÕ½Ðì¤((ìÍ¥µÁ±ÍÉÙÈÁɽɴѼɥٵÍÍÌɽ´±¥¹Ð¹¥ÍÁ±äÑ¡´((ìQ¡±¥¹ÐÝ¥±°Í¹Ñ¡µÍÍÅÕ½Ðí¡±±¼ÅÕ½Ðì°½±±½ÝäÍɥ̽ɹ½´¹ÕµÉÌ(ìQ¡ÍÉÙÈÝ¥Ñ̽ȱ¥¹ÐѼ͹ѡµÍÍÅÕ½Ðí¡±±¼ÅÕ½ÐììÑ¡¥ÌÑÌÙÉäÍ¥µÁ±ÁÍÍݽɰ(ì%¹¡Ù¥¹É¥ÙѡеÍÍ°Ñ¡ÍÉÙÈ¥ÍÁ±åÌÕÉѡȵÍÍÌÑ¡ÐÑ¡±¥¹Ð͹Ì((ìÍ¥¹±ÍÉÙȸ½ÁÝ¥Ñ ÍÙÉ°±¥¹ÑÌÐѡ͵ѥµ(ìQ¡ÉÉäÀÌØíͽ­ÑÉÉåmt¡½±ÌÑ¡¥Èͽ­Ð¥¹Ñ¥¥ÉÌ°¹Ñ¡Áɱ±°ÉÉä(ì$ÀÌØíͽ­ÑÕÑ¡¹Ñ¥Ñmt¡½±ÌÑ¡Ù±ÕÀ½È ͽ­Ðչѥ°Ñ¡Í½­Ð¡Ì͹ÐÑ¡ÅÕ½ÐíÁÍÍݽÉÅÕ½Ðì((ìQ¡ÍÉÙȱ½½­Ì½ÈµÍÍ̹¥ÍÁ±åÌÑ¡´ÙÉäÄÀͽ¹Ì()±½°ÀÌØí½¹¹Ñͽ­Ñ±ôÀ)±½°ÀÌØíá¥Ñ±½½Á±ôÀ)±½°ÀÌØí¹½½¹¹Ñ¥½¹ÌôÀ)±½°ÀÌØí½¹¹Ñ¥½¹±¥µ¥ÐôÌ)±½°ÀÌØíͽ­ÑÉÉålÀÌØí½¹¹Ñ¥½¹±¥µ¥Ð¬Åt)±½°ÀÌØíͽ­ÑÕÑ¡¹Ñ¥ÑlÀÌØí½¹¹Ñ¥½¹±¥µ¥Ð¬Åt()1½°ÀÌØíÑ¥µÍѵÀ°ÀÌØíµ¥¹½ÕÑÁÕÑ¡¹±°ÀÌØíµ¥¹½ÕÑÁÕÑÑáÐ)1½°ÀÌØí½Õ¹Ð°ÀÌØíµÑ ((ÀÌØíÑ¥µÍѵÀôQ¥µÉ%¹¥Ð ¤((ì
ÉÑÑ¡Ý¥¹½Ü¥Ñͱ(ÀÌØíµ¥¹½ÕÑÁÕÑ¡¹±ôU%
ÉÑ ÅÕ½ÐíMÉÙÈÅÕ½Ðì°ÐÀÀ°ÈÀÀ°À°À¤)U%MÑMÑÑ¡M]}M!=¤((ì
ÉѸɽÈÍåÍÑ´µÍÍÌ(ÀÌØíµ¥¹½ÕÑÁÕÑÑáÐôU%
Ñɱ
ÉѥРÅÕ½ÐìÅÕ½Ðì°ÄÀ°ÄÀ°ÌàÀ°ÄàÀ° ¥Ñ=H ÀÌØíM}5U1Q%1%9°ÀÌØíM}I=91d°ÀÌØí]M}YM
I=10°ÀÌØí]M}   =IH¤¤)U%
ÑɱMÑ
½±½È ÀÌØíµ¥¹½ÕÑÁÕÑÑáаÁá¤)U%
ÑɱMÑ   ­
½±½È ÀÌØíµ¥¹½ÕÑÁÕÑÑáаÁàÀÀÀÀÀÀ¤($$(ìMÑÉÐÑ¡ÍÉÙÈ)}U%
Ñɱ¥Ñ}ÁÁ¹QáÐ ÀÌØíµ¥¹½ÕÑÁÕÑÑáаÅÕ½ÐíMÑÉÑ¥¹ÍÉÙȡȹÍÉ¥ÁФÅÕ½ÐìµÀì
I1¤(ÀÌØíÉÍÕ±ÐôQ
AMÑÉÑÕÀ ¤)%ÀÌØíÉÍÕ±ÐôÀQ¡¸(%}U%
Ñɱ¥Ñ}ÁÁ¹QáÐ ÀÌØíµ¥¹½ÕÑÁÕÑÑáаÅÕ½ÐíQ
AMÑÉÑUÀ ¤¥±¸ÅÕ½ÐìµÀì
I1¤(%Q
AM¡Õѽݸ ¤(%M±À ÌÀÀÀ¤(%á¥Ð)¹%($$(ì
ÉÑͽ­Ð½È¸¥¹½µ¥¹½¹¹Ñ¥½¸¸(ÀÌØíµ¥¹Í½­ÐôQ
A1¥ÍѸ ÅÕ½ÐìÄäȸÄØà¸Ä¸ÄÀÄÅÕ½Ðì°ÄÀÀÀ¤)%ÀÌØíµ¥¹Í½­Ðô´ÄQ¡¸(%}U%
Ñɱ¥Ñ}ÁÁ¹QáÐ ÀÌØíµ¥¹½ÕÑÁÕÑÑáаÅÕ½ÐíQ
A1¥ÍѸ ¤¥±¸ÅÕ½ÐìµÀì
I1¤(%Q
AM¡Õѽݸ ¤(%M±À ÌÀÀÀ¤(%á¥Ð)±Í($ì}U%
Ñɱ¥Ñ}ÁÁ¹QáÐ ÀÌØíµ¥¹½ÕÑÁÕÑÑáаÅÕ½Ðí½Õ¹Í½­Ð°¥¹Ñ¥¥ÈÅÕ½ÐìµÀìÀÌØíµ¥¹Í½­ÐµÀì
I1¤)¹%($(ìÁеÍÍÌչѥ°Ñ¡È¡½Ñ­ä¥ÌÁÉÍÍ)¼($($ì%Ñ¡¹ÕµÈ½½¹¹Ñ¥½¹Ì¥Í¸ÌäíбÉäÐ¥Ñ̵᥵մ°±½½¬½È¹Ü½¹¹Ñ¥½¸(%%ÀÌØí¹½½¹¹Ñ¥½¹Ì±ÐìÀÌØí½¹¹Ñ¥½¹±¥µ¥ÐQ¡¸($$ÀÌØí¹Ýͽ­ÐôQ
AÁÐ ÀÌØíµ¥¹Í½­Ð¤($%%ÀÌØí¹Ýͽ­Ðô´ÄQ¡¸($$$ì9¼¹Ü½¹¹Ñ¥½¹ÌÝɽչ($%±Í($$$ì¹Ü½¹¹Ñ¥½¸Ý̽չ($$$ÀÌØí¹½½¹¹Ñ¥½¹ÌôÀÌØí¹½½¹¹Ñ¥½¹Ì¬Ä($$$쥹À¥¸Ñ¡ÉÉäÀÌØíͽ­ÑÉÉä($$$ÀÌØíµÑ ôÀ($$%½ÈÀÌØí½Õ¹ÐôÄѼÀÌØí½¹¹Ñ¥½¹±¥µ¥Ð($$$%%ÀÌØíµÑ ôÀ9ÀÌØíͽ­ÑÉÉålÀÌØí½Õ¹ÑtôÅÕ½ÐìÅÕ½ÐìQ¡¸($$$$$ÀÌØíµÑ ôÀÌØí½Õ¹Ð($$$$$ÀÌØíͽ­ÑÉÉålÀÌØíµÑ¡tôÀÌØí¹Ýͽ­Ð($$$%¹%($$%9áÐ($$%}U%
Ñɱ¥Ñ}ÁÁ¹QáÐ ÀÌØíµ¥¹½ÕÑÁÕÑÑáаÅÕ½Ðí
±¥¹ÐÑѰͽ­Ð¹¼èÅÕ½ÐìµÀìÀÌØíͽ­ÑÉÉålÀÌØíµÑ¡tµÀìÅÕ½Ðì°½¹¹Ñ¥½¹ÌèÅÕ½ÐìµÀìÀÌØí¹½½¹¹Ñ¥½¹ÌµÀì
I1¤($%¹%$(%¹%($($ì
¡¬ ½¹¹Ñ¥½¸½ÈµÍÍ(%½ÈÀÌØí½Õ¹ÐôÄѼÀÌØí½¹¹Ñ¥½¹±¥µ¥Ð($$ì=¹±ä±½½¬½ÈµÍÍɽ´¸Ñ¥Ù½¹¹Ñ¥½¸($%%ÀÌØíͽ­ÑÉÉålÀÌØí½Õ¹Ñt±ÐìÐìÅÕ½ÐìÅÕ½ÐìQ¡¸$$$($$$ÀÌØíÑôQ
AIØ ÀÌØíͽ­ÑÉÉålÀÌØí½Õ¹Ñt°ÔÄȤ($$$ìQ¡±¥¹Ð¡Ì±½ÍÑ¡½¹¹Ñ¥½¸($$%%ÉɽÈQ¡¸($$$$ÀÌØíͽ­ÑÉÉålÀÌØí½Õ¹ÑtôÅÕ½ÐìÅÕ½Ðì($$$%}U%
Ñɱ¥Ñ}ÁÁ¹QáÐ ÀÌØíµ¥¹½ÕÑÁÕÑÑáаÅÕ½Ðí
±¥¹Ð¹¼¸ÅÕ½ÐìµÀìÀÌØí½Õ¹ÐµÀìÅÕ½ÐìÑɵ¥¹Ñ½¹¹Ñ¥½¸¸ÅÕ½ÐìµÀì
I1¤($$$$ÀÌØí¹½½¹¹Ñ¥½¹ÌôÀÌØí¹½½¹¹Ñ¥½¹Ì´Ä($$%±Í%ÀÌØíÑôÅÕ½ÐìÅÕ½ÐìQ¡¸($$$$ì}U%
Ñɱ¥Ñ}ÁÁ¹QáÐ ÀÌØíµ¥¹½ÕÑÁÕÑÑáаÀÌØí½Õ¹ÐµÀìÅÕ½Ðì%9¼Ñ¸ÅÕ½ÐìµÀì
I1¤($$%±Í%ÀÌØíÑôÅÕ½Ðí!±±¼ÅÕ½ÐìQ¡¸($$$%}U%
Ñɱ¥Ñ}ÁÁ¹QáÐ ÀÌØíµ¥¹½ÕÑÁÕÑÑáаÅÕ½ÐíI¥ÙÌäí¡±±¼Ìäìɽ´±¥¹Ð¹¼èÅÕ½ÐìµÀìÀÌØí½Õ¹ÐµÀì
I1¤($$$$ìIÁ±äѼѡ±¥¹Ð°Í她ѡÐÑ¡ÁÍÍݽɡ̸ɥٹÁÑ($$$%Q
AM¹ ÀÌØíͽ­ÑÉÉålÀÌØí½Õ¹Ñt°ÅÕ½Ðí!±±¼å½ÕÉͱÅÕ½Ðì¤($$$$ÀÌØíͽ­ÑÕÑ¡¹Ñ¥ÑlÀÌØí½Õ¹ÑtôÄ($$%±Í%ÀÌØíͽ­ÑÕÑ¡¹Ñ¥ÑlÀÌØí½Õ¹ÑtôÄQ¡¸($$$%}U%
Ñɱ¥Ñ}ÁÁ¹QáÐ ÀÌØíµ¥¹½ÕÑÁÕÑÑáаÅÕ½ÐíI¥ÙÑɽ´±¥¹Ð¹¼èÅÕ½ÐìµÀìÀÌØí½Õ¹ÐµÀìÅÕ½Ðì°ÑèÅÕ½ÐìµÀìÀÌØíѵÀì
I1¤($$$%   À ÄÔÀÀ°ÄÀÀ¤($$%¹%($%¹%(%9áÐ($$(%M±À ÄÀÀÀ¤()U¹Ñ¥°ÀÌØíá¥Ñ±½½Á±ôÄ((ì¹Ñ¡ÍÉ¥ÁÐ)}U%
Ñɱ¥Ñ}ÁÁ¹QáÐ ÀÌØíµ¥¹½ÕÑÁÕÑÑáаÅÕ½Ðí
±½Í¥¹ÍÉ¥ÁиÅÕ½ÐìµÀì
I1¤((ì%¹ä±¥¹ÑÌ¡Ù¸ÌäíХͽ¹¹Ð°¥Í½¹¹ÐÑ¡´¹½Ü)½ÈÀÌØí½Õ¹ÐôÄѼÀÌØí½¹¹Ñ¥½¹±¥µ¥Ð(%%ÀÌØíͽ­ÑÉÉålÀÌØí½Õ¹Ñt±ÐìÐìÅÕ½ÐìÅÕ½ÐìQ¡¸($%Q
A
±½ÍM½­Ð ÀÌØíͽ­ÑÉÉålÀÌØí½Õ¹Ñt¤($%}U%
Ñɱ¥Ñ}ÁÁ¹QáÐ ÀÌØíµ¥¹½ÕÑÁÕÑÑáаÅÕ½Ðí
±½Í¥¹½¹¹Ñ¥½¸Ý¥Ñ ±¥¹Ð¹¼¸ÅÕ½ÐìµÀìÀÌØí½Õ¹ÐµÀì
I1¤(%¹%)9áÐ()Q
AM¡Õѽݸ ¤)M±À ÌÀÀÀ¤)á¥Ð()Õ¹Qɵ¥¹ÑMÉ¥ÁÐ ¤($ìAÉÍÍ¥¹Ñ¡¡½Ñ­äÍṈ̃½°ÙÉ¥±Ñ¡ÐÑɵ¥¹ÑÌ($ìÑ¡½¹¹Ñ¥½¸½¸Ñ¡¹áб½½À($ÀÌØíá¥Ñ±½½Á±ôÄ($(%IÑÕɸ()¹Õ¹oÝ÷ Ù«­¢+Øì
1%9P((¥¹±Õ±Ðí5¥Í¹ÔÌÐì(¥¹±Õ±ÐíU%
½¹ÍѹÑ̹ÔÌÐì(¥¹±Õ±ÐíѹÔÌÐì(¥¹±Õ±ÐíÕ¥¥Ð¹ÔÌÐì(¥¹±Õ±ÐíÍÑÉ¥¹¹ÔÌÐì((ìM¹ÌÁÍÍݽÉѼѡÍÉÙÈ(ì]¡¸¥ÐÉ¥ÙÌÉÁ±ä°Ñ¡ÍÉ¥ÁÐ͹ÌѸ¹ÕµÉÌѼѡÍÉÙȹÑɵ¥¹ÑÌ()1½°ÀÌØíÑ¥µÍѵÀ°ÀÌØíµ¥¹½ÕÑÁÕÑ¡¹±°ÀÌØíµ¥¹½ÕÑÁÕÑÑáаÀÌØí½Õ¹Ð°ÀÌØíµÍÍ)1½°ÀÌØíÍÁ±½½Á±ôÀ((ÀÌØíÑ¥µÍѵÀôQ¥µÉ%¹¥Ð ¤((ì
ÉÑÑ¡Ý¥¹½Ü¥Ñͱ(ÀÌØíµ¥¹½ÕÑÁÕÑ¡¹±ôU%
ÉÑ ÅÕ½Ðí
±¥¹ÐÅÕ½Ðì°ÐÀÀ°ÈÀÀ°ÔÀÀ°À¤)U%MÑMÑÑ¡M]}M!=¤((ì
ÉѸɽȵÍÍÌ(ÀÌØíµ¥¹½ÕÑÁÕÑÑáÐôU%
Ñɱ
ÉѥРÅÕ½ÐìÅÕ½Ðì°ÄÀ°ÄÀ°ÌàÀ°ÄàÀ° ¥Ñ=H ÀÌØíM}5U1Q%1%9°ÀÌØíM}I=91d°ÀÌØí]M}YM
I=10°ÀÌØí]M}   =IH¤¤)U%
ÑɱMÑ
½±½È ÀÌØíµ¥¹½ÕÑÁÕÑÑáаÁá¤)U%
ÑɱMÑ   ­
½±½È ÀÌØíµ¥¹½ÕÑÁÕÑÑáаÁàÀÀÀÀÀÀ¤)}U%
Ñɱ¥Ñ}ÁÁ¹QáÐ ÀÌØíµ¥¹½ÕÑÁÕÑÑáаÅÕ½ÐíMÑÉÑ¥¹±¥¹ÐÅÕ½ÐìµÀì
I1¤((ì¥ÉÍÐ͹¡±±¼µÍÍ°¹Ý¥Ð½ÈÉÁ±ä(ì%¥Ð½Í¸ÌäíÐÉÉ¥Ùݥѡ¥¸Ìͽ¹Ì°±½ÍÑ¡½¹¹Ñ¥½¸¹ÑÉ䥸)¼(%Q
AMÑÉÑÕÀ ¤($ÀÌØíͽ­ÐôQ
A
½¹¹Ð ÅÕ½ÐìÄäȸÄØà¸Ä¸ÄÀÄÅÕ½Ðì°ÄÀÀÀ¤(%Q
AM¹ ÀÌØíM½­Ð°ÅÕ½Ðí!±±¼ÅÕ½Ðì¤($(%½ÈÀÌØí½Õ¹ÐôÄѼÌ($%%ÀÌØíÍÁ±½½Á±ôÀQ¡¸($$%M±À ÄÀÀÀ¤($$$ÀÌØíÑôQ
AIØ ÀÌØíͽ­Ð°ÔÄȤ($$%%ÀÌØíÑôÅÕ½Ðí!±±¼å½ÕÉͱÅÕ½ÐìQ¡¸($$$%}U%
Ñɱ¥Ñ}ÁÁ¹QáÐ ÀÌØíµ¥¹½ÕÑÁÕÑÑáаÅÕ½Ðí1½¥¸Ñ¼ÍÉÙȸÅÕ½ÐìµÀì
I1¤($$$$ÀÌØíÍÁ±½½Á±ôÄ($$%¹%($%¹%(%9áÐ($(%%ÀÌØíÍÁ±½½Á±ôÀQ¡¸($$ì
±½ÍÑ¡½¹¹Ñ¥½¸($%Q
A
±½ÍM½­Ð ÀÌØíM½­Ð¤($%Q
AM¡Õѽݸ ¤($$ìQÉ䥸¥¸ÄÀͽ¹Ì($%}U%
Ñɱ¥Ñ}ÁÁ¹QáÐ ÀÌØíµ¥¹½ÕÑÁÕÑÑáаÅÕ½Ðí
½Õ±¸ÌäíÐÍѱ¥Í ½¹¹Ñ¥½¸Ý¥Ñ ÍÉÙȸÅÕ½ÐìµÀì
I1¤($%M±À ÔÀÀÀ¤(%¹%($)U¹Ñ¥°ÀÌØíÍÁ±½½Á±ôÄ((ìM¹Ñ¸µÍÍÌÐɹ½´¥¹ÑÉÙ±Ì()½ÈÀÌØíôÄѼÄÀ(%M±À¡I¹½´ ÌÀÀÀ°ÔÀÀÀ¤¤($ÀÌØíµÍÍô±½½È¡Q¥µÉ¥ ÀÌØíÑ¥µÍѵÀ¤¤(%}U%
Ñɱ¥Ñ}ÁÁ¹QáÐ ÀÌØíµ¥¹½ÕÑÁÕÑÑáаÅÕ½ÐíM¹¥¹Ñ¡µÍÍÅÕ½ÐìµÀìÀÌØíµÍ͵Àì
I1¤(%Q
AM¹ ÀÌØíM½­Ð°ÀÌØíµÍͤ(%    À ÄÀÀÀ°ÄÀÀ¤)9áÐ()U%
ÑɱMÑÑ ÀÌØíµ¥¹½ÕÑÁÕÑÑáаU%
ÑɱI ÀÌØíµ¥¹½ÕÑÁÕÑÑáФµÀì
I1µÀìÅÕ½Ðí
±½Í¥¹½Ý¸¥¸Ôͽ¹ÌÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì¤$)M±À ÔÀÀÀ¤()Q
A
±½ÍM½­Ð ÀÌØíM½­Ð¤)Q
AM¡Õѽݸ ¤

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×