From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: "Nick S. Grechukh" To: community@altlinux.ru Subject: Re: [Comm] read from socket Date: Fri, 11 Feb 2005 14:41:33 +0200 User-Agent: KMail/1.7.2 References: <200502111200.22014.ngrechukh@ua.fm> <420C8A56.1050400@unisoft.com.ua> <200502111243.06160.ngrechukh@ua.fm> In-Reply-To: <200502111243.06160.ngrechukh@ua.fm> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart1163931.2Oc1f3zKlR"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <200502111441.39076.ngrechukh@ua.fm> X-Virus-Scanned: ClamAV 0.82/704/Thu Feb 10 13:37:18 2005 on flash.zp.ukrtel.net X-Virus-Status: Clean X-BeenThere: community@altlinux.ru X-Mailman-Version: 2.1.5 Precedence: list Reply-To: community@altlinux.ru List-Id: Mailing list for ALT Linux users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Feb 2005 12:39:00 -0000 Archived-At: List-Archive: List-Post: --nextPart1163931.2Oc1f3zKlR Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline =D7=CF=D4 =DE=D4=CF-=D4=CF =D7 =DC=D4=CF=CD =D2=CF=C4=C5 =D0=CF=CC=D5=DE=C9= =CC=CF=D3=D8, =D0=CF=D2=D5=C7=C1=CA=D4=C5: typedef struct { char signature[8]; int command; size_t msgsize; } ctrl_header; int operate(int sock, sq_command command, void * response, size_t len_buff) { char *recvbuf; int n; ctrl_header hdr; memcpy(hdr.signature,"SQ1.0.00\n",10); hdr.command=3D1; hdr.msgsize=3D0; n =3D send(sock, &hdr, sizeof(hdr),0); n =3D recv(sock, &hdr, sizeof(hdr),MSG_WAITALL); if ((n=3D=3Dsizeof(hdr)) && (strncmp(hdr.signature,"SQ1.0.00\n",10)=3D=3D0= )){ if (hdr.msgsize>0){ if ((recvbuf=3Dmalloc(hdr.msgsize))!=3DNULL){ if ((n =3D recv(sock,recvbuf, hdr.msgsize, MSG_WAITALL))=3D=3Dhdr.msgsi= ze){ if ((response!=3DNULL) && (len_buff>=3D0)) { memcpy(response,recvbuf,len_buff); } } else { //maybe socket error, count of received data