Changeset 0bbef9b in mainline for uspace/app/nettest1/nettest.c
- Timestamp:
- 2010-11-06T22:54:25Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5f69504
- Parents:
- 1712f87
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/nettest1/nettest.c
r1712f87 r0bbef9b 36 36 37 37 #include <stdio.h> 38 #include <err.h>39 40 38 #include <net/socket.h> 41 39 … … 87 85 int sockets_close(int verbose, int *socket_ids, int sockets) 88 86 { 89 ERROR_DECLARE; 90 91 int index; 87 int index; 88 int rc; 92 89 93 90 if (verbose) … … 97 94 98 95 for (index = 0; index < sockets; index++) { 99 if (ERROR_OCCURRED(closesocket(socket_ids[index]))) { 96 rc = closesocket(socket_ids[index]); 97 if (rc != EOK) { 100 98 printf("Socket %d (%d) error:\n", index, socket_ids[index]); 101 socket_print_error(stderr, ERROR_CODE, "Socket close: ", "\n");102 return ERROR_CODE;99 socket_print_error(stderr, rc, "Socket close: ", "\n"); 100 return rc; 103 101 } 104 102 if (verbose) … … 121 119 int sockets_connect(int verbose, int *socket_ids, int sockets, struct sockaddr *address, socklen_t addrlen) 122 120 { 123 ERROR_DECLARE; 124 125 int index; 121 int index; 122 int rc; 126 123 127 124 if (verbose) … … 131 128 132 129 for (index = 0; index < sockets; index++) { 133 if (ERROR_OCCURRED(connect(socket_ids[index], address, addrlen))) { 134 socket_print_error(stderr, ERROR_CODE, "Socket connect: ", "\n"); 135 return ERROR_CODE; 130 rc = connect(socket_ids[index], address, addrlen); 131 if (rc != EOK) { 132 socket_print_error(stderr, rc, "Socket connect: ", "\n"); 133 return rc; 136 134 } 137 135 if (verbose) … … 157 155 int sockets_sendto(int verbose, int *socket_ids, int sockets, struct sockaddr *address, socklen_t addrlen, char *data, int size, int messages) 158 156 { 159 ERROR_DECLARE;160 161 157 int index; 162 158 int message; 159 int rc; 163 160 164 161 if (verbose) … … 169 166 for (index = 0; index < sockets; index++) { 170 167 for (message = 0; message < messages; message++) { 171 if (ERROR_OCCURRED(sendto(socket_ids[index], data, size, 0, address, addrlen))) { 172 printf("Socket %d (%d), message %d error:\n", index, socket_ids[index], message); 173 socket_print_error(stderr, ERROR_CODE, "Socket send: ", "\n"); 174 return ERROR_CODE; 168 rc = sendto(socket_ids[index], data, size, 0, address, addrlen); 169 if (rc != EOK) { 170 printf("Socket %d (%d), message %d error:\n", index, socket_ids[index], message); 171 socket_print_error(stderr, rc, "Socket send: ", "\n"); 172 return rc; 175 173 } 176 174 } … … 239 237 int sockets_sendto_recvfrom(int verbose, int *socket_ids, int sockets, struct sockaddr *address, socklen_t *addrlen, char *data, int size, int messages) 240 238 { 241 ERROR_DECLARE;242 243 239 int value; 244 240 int index; 245 241 int message; 242 int rc; 246 243 247 244 if (verbose) … … 252 249 for (index = 0; index < sockets; index++) { 253 250 for (message = 0; message < messages; message++) { 254 if (ERROR_OCCURRED(sendto(socket_ids[index], data, size, 0, address, *addrlen))) { 255 printf("Socket %d (%d), message %d error:\n", index, socket_ids[index], message); 256 socket_print_error(stderr, ERROR_CODE, "Socket send: ", "\n"); 257 return ERROR_CODE; 251 rc = sendto(socket_ids[index], data, size, 0, address, *addrlen); 252 if (rc != EOK) { 253 printf("Socket %d (%d), message %d error:\n", index, socket_ids[index], message); 254 socket_print_error(stderr, rc, "Socket send: ", "\n"); 255 return rc; 258 256 } 259 257 value = recvfrom(socket_ids[index], data, size, 0, address, addrlen);
Note:
See TracChangeset
for help on using the changeset viewer.