- 论坛徽章:
- 0
|
- int main(int argc, char *argv[])
- {
- struct sockaddr_in send_addr, rec_addr;
- send_addr.sin_family = AF_INET;
- send_addr.sin_addr.s_addr = inet_addr(argv[1]);
- send_addr.sin_port = htons(atoi(argv[2]));
- rec_addr.sin_family = AF_INET;
- rec_addr.sin_addr.s_addr = inet_addr(argv[3]);
- rec_addr.sin_port = htons(atoi(argv[4]));
- printf("%s:%d %s:%d\n",inet_ntoa(send_addr.sin_addr), ntohs(send_addr.sin_port),
- inet_ntoa(rec_addr.sin_addr), ntohs(rec_addr.sin_port));
- return 0;
- }
复制代码 不知道为什么输出的send_addr, rec_addr的IP永远是一样的,而端口号设定却没问题 |
|