Skip to content

Commit 5ed03ae

Browse files
committed
add some coments and fix non-block connect issue in dpdk_tcp_client.c
1 parent d5331ff commit 5ed03ae

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

librte_anssock/include/anssock_intf.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ int anssock_bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
109109
* @param sockfd
110110
* @param buf
111111
* @param len
112-
* @param flags
112+
* @param flags: don't support MSG_OOB
113113
* @param dest_addr
114114
* @param addrlen
115115
*
@@ -127,7 +127,7 @@ ssize_t anssock_sendto(int sockfd, const void *buf, size_t len, int flags,
127127
* @param sockfd
128128
* @param buf
129129
* @param len
130-
* @param flags
130+
* @param flags: don't support MSG_OOB
131131
*
132132
* @return
133133
* On success, these calls return the number of characters sent. On error, -1 is returned, and errno is set appropriately.

test/dpdk_tcp_client/dpdk_tcp_client.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ int main(void)
216216
remote_addr.sin_port = htons(8000);
217217
remote_addr.sin_addr.s_addr = inet_addr("10.0.0.10"); ;
218218

219-
if(anssock_connect(fd[i], (struct sockaddr *)&remote_addr, sizeof(struct sockaddr)) < 0)
219+
if(anssock_connect(fd[i], (struct sockaddr *)&remote_addr, sizeof(struct sockaddr)) < 0 && errno != EINPROGRESS)
220220
{
221221
printf("connect to server failed \n");
222222
anssock_close(fd[i]);
@@ -288,14 +288,20 @@ int main(void)
288288
recv_len = anssock_recvfrom(events[i].data.fd, recv_buf, 5000, 0, NULL, NULL);
289289
if((recv_len < 0) && (errno == ANS_EAGAIN))
290290
{
291-
// printf("no data in socket \n");
291+
// printf("no data in socket \n");
292292

293293
break;
294294
}
295-
else if(recv_len < 0)
295+
else if(recv_len <= 0)
296296
{
297297
// socket error
298-
//anssock_close(fd);
298+
printf("socket error \n");
299+
anssock_close(events[i].data.fd);
300+
for(j = 0; j < TCP_CLIENT_NB; j++)
301+
{
302+
if(fd[j] == events[i].data.fd)
303+
fd[j] = -1;
304+
}
299305
break;
300306

301307
}

0 commit comments

Comments
 (0)