socket programming

Thread Starter

ecjohnny

Joined Jul 16, 2005
142
can anyone with socket programming help me out?
I am trying to implement stop and wait protocol.

https://www.dropbox.com/s/sv1yywzrr52w0j4/tcp_client3.c
https://www.dropbox.com/s/922uryv8zzm3tlx/tcp_ser3.c
https://www.dropbox.com/s/jg6s7opjcbkph66/headsock.h

My results seems wrong. My client is sending a text file to server. The client output is right but the server is wrong. My server only receive part of it, about 300 bytes short. Also, my server is not getting right packet size. E.g client sent 1800 byte, my server only receive about 1440 per trip.

Just to clarify if someone spot this as mistake, I use "break" early in my server because n= -1 and will give me error. Any help?
 

Thread Starter

ecjohnny

Joined Jul 16, 2005
142
No. However, there is a packet length provided for me in headsock.h
is packet length = data length?
i have set data length which i suppose i have split it into packet using data length ??

+It works(data length = 500,600 etc..) till when i set data length to 1700. Meaning it went wrong when i try to split the data into 1700 of 59,792(a text file) bytes.
Any idea what/why happen?
 
Last edited:

tshuck

Joined Oct 18, 2012
3,534
Yes, what I meant was the data length... everything else should be appended by the packet transmitter, as that is protocol specific...

Have you tried packet sniffing using Wireshark? It is great at this sort of thing...
 

Thread Starter

ecjohnny

Joined Jul 16, 2005
142
hey.. can i know if i am right that the reason why i can't set my data length to 1700 is because of MTU which limit my packet size. MTU is typically 1500 bytes.
i google abit on MTU but i am still confuse if that is the reason.
 

tshuck

Joined Oct 18, 2012
3,534
hmmm... that would make sense... I've never made that big of transmissions, so it would explain why I've never seen it....:)
 
Top