当前位置: 技术问答>linux和unix
网络编程中怎么样得到自己的端口?
来源: 互联网 发布时间:2015-04-16
本文导语: //我现在写了以下函数: int connect_udp(char *host_name, int port) { int udpfd = socket(AF_INET, SOCK_DGRAM, 0); struct sockaddr_in their_addr; if (udpfd h_addr_list); their_addr.sin_port = htons(port); ret = connect(udpfd, (struct sockaddr*)&t...
//我现在写了以下函数:
int connect_udp(char *host_name, int port)
{
int udpfd = socket(AF_INET, SOCK_DGRAM, 0);
struct sockaddr_in their_addr;
if (udpfd h_addr_list);
their_addr.sin_port = htons(port);
ret = connect(udpfd, (struct sockaddr*)&their_addr, sizeof(struct sockaddr));
if (ret
int connect_udp(char *host_name, int port)
{
int udpfd = socket(AF_INET, SOCK_DGRAM, 0);
struct sockaddr_in their_addr;
if (udpfd h_addr_list);
their_addr.sin_port = htons(port);
ret = connect(udpfd, (struct sockaddr*)&their_addr, sizeof(struct sockaddr));
if (ret