Undo using the sreadfrom() wrapper to replace recvfrom() in our code.

This commit is contained in:
Yang Tse 2008-07-30 05:10:42 +00:00
parent de8e362d4a
commit 537490e391
2 changed files with 16 additions and 11 deletions

View File

@ -717,7 +717,7 @@ static CURLcode tftp_do(struct connectdata *conn, bool *done)
CURLcode code;
int rc;
struct Curl_sockaddr_storage fromaddr;
RECVFROM_ARG6_T fromlen;
socklen_t fromlen;
int check_time = 0;
struct SingleRequest *k = &data->req;
@ -764,10 +764,13 @@ static CURLcode tftp_do(struct connectdata *conn, bool *done)
else {
/* Receive the packet */
fromlen = (RECVFROM_ARG6_T)sizeof(fromaddr);
state->rbytes = sreadfrom(state->sockfd,
&state->rpacket, sizeof(state->rpacket),
&fromaddr, &fromlen);
fromlen = sizeof(fromaddr);
state->rbytes = (ssize_t)recvfrom(state->sockfd,
(void *)&state->rpacket,
sizeof(state->rpacket),
0,
(struct sockaddr *)&fromaddr,
&fromlen);
if(state->remote_addrlen==0) {
memcpy(&state->remote_addr, &fromaddr, fromlen);
state->remote_addrlen = fromlen;

View File

@ -132,7 +132,7 @@ static int maxtimeout = 5*TIMEOUT;
static char buf[PKTSIZE];
static char ackbuf[PKTSIZE];
static struct sockaddr_in from;
static RECVFROM_ARG6_T fromlen;
static socklen_t fromlen;
struct bf {
int counter; /* size of data in buffer, or flag */
@ -355,7 +355,7 @@ static int synchnet(curl_socket_t f /* socket to flush */)
int j = 0;
char rbuf[PKTSIZE];
struct sockaddr_in fromaddr;
RECVFROM_ARG6_T fromaddrlen;
socklen_t fromaddrlen;
while (1) {
#if defined(HAVE_IOCTLSOCKET)
@ -365,8 +365,9 @@ static int synchnet(curl_socket_t f /* socket to flush */)
#endif
if (i) {
j++;
fromaddrlen = (RECVFROM_ARG6_T)sizeof(fromaddr);
(void)sreadfrom(f, rbuf, sizeof(rbuf), &fromaddr, &fromaddrlen);
fromaddrlen = sizeof(fromaddr);
(void)recvfrom(f, rbuf, sizeof(rbuf), 0,
(struct sockaddr *)&fromaddr, &fromaddrlen);
}
else
break;
@ -513,8 +514,9 @@ int main(int argc, char **argv)
, port );
do {
fromlen = (RECVFROM_ARG6_T)sizeof(from);
n = sreadfrom(sock, buf, sizeof(buf), &from, &fromlen);
fromlen = sizeof(from);
n = (ssize_t)sreadfrom(sock, buf, sizeof(buf), 0,
(struct sockaddr *)&from, &fromlen);
if (n < 0) {
logmsg("recvfrom:\n");
result = 3;