www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/01/21/11:21:32

From: Richard Dawe <rich AT phekda DOT freeserve DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: libsocket over the net...
Date: Sun, 21 Jan 2001 15:26:50 +0000
Organization: Customer of Energis Squared
Lines: 66
Message-ID: <3A6AFFBA.5DB1B739@phekda.freeserve.co.uk>
References: <3A69FEFF DOT 7020104 AT operamail DOT com> <3A6A28C3 DOT 502361A2 AT phekda DOT freeserve DOT co DOT uk> <3A6A6E2B DOT 7000204 AT operamail DOT com>
NNTP-Posting-Host: modem-6.emperor-angel.dialup.dialup.pol.co.uk
Mime-Version: 1.0
X-Trace: news6.svr.pol.co.uk 980093198 23452 62.137.6.6 (21 Jan 2001 16:06:38 GMT)
NNTP-Posting-Date: 21 Jan 2001 16:06:38 GMT
X-Complaints-To: abuse AT theplanet DOT net
X-Mailer: Mozilla 4.51 [en] (X11; I; Linux 2.2.17 i586)
X-Accept-Language: de,fr
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hello.

Sahab Yazdani wrote:
> > How are they garbled? Are the data in the wrong order? Do you get any
> > of the sent data when you do recv()?
> 
> ok, i've been messing around with it a bit and have made a great deal of
> headway...  i have gotten it to transmit a "MassacreHeader" structure
> over the network everytime perfectly.  The problem now comes when I try
> to transmit the other two structure types: "MassacreChatPacket" and
> "MassacreBriefingRoomPacket".

What did you change? Why is the data no longer garbled? Knowing this could
help fix your other problems.

> I believe that this is because the packets are not getting there
> completely, and that my method just trucates it and then the error
> checking routines convert the data into error values (which is only the
> *name* field, the type and player field are garbled by the routines).

What type of sockets are you creating - TCP/IP or UDP/IP? E.g. are you
using:

- socket(AF_INET, SOCK_STREAM, IPPROTO_TCP) for TCP/IP;
- or socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP) for UDP/IP?

(Actually, you should use PF_INET instead of AF_INET.)

You should be able to send your headers in one packet, since they are
small.

> as a side note, when I print out the error using either lsck_perror or
> perror, i get this message "RETRIEVE1: Resource temporarily not
> available (EAGAIN)" over and over again with a stray "RETREIVE2: " " " "
> popping in there sometimes (only when data is being sent over the
> network).

Which version of Windows are you using? Do you have Winsock 2 installed?
What does the libsocket demo program demo/diag.exe display? You can
capture its output like so:

    redir -eo diag.exe > diag.out

I've never seen this error, but other people have reported it. Perhaps it
only occurs with a small packet size? Strange. I would like to know why
that happens.

[snip]
> MassacreHeader CreateHeader( unsigned char packetType, unsigned char multiples ) {
>         MassacreHeader retType;
> 
>         strcpy(retType.header, "MASS" );

Since retType.Header is a 4 char array, this will overflow the buffer and
overwrite retType.packetType, because "MASS" is 5 bytes - 'MASS\0'. If you
want space for the nul terminator, make header a 5 char array.

I still can't see anything wrong with the rest of your code.

Bye, 

-- 
Richard Dawe <richdawe AT bigfoot DOT com> http://www.bigfoot.com/~richdawe/ 

"The soul is the mirror of an indestructible universe."
--- Gottfried W. Leibniz

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019