linux下网络编程 端口设置的问题
#include "csapp.h"
#define MAX_ARG_NUM 10
#define MAXLINE 512
#define PEER_PORT 1719
struct Udp2SipMsg
{
int argc;
char *argv[MAX_ARG_NUM];
char buf[MAXLINE];
} udp2sipmsg;
char *sendbuf;
char *recvbuf;
struct sockaddr_in host,peer;
struct hostent *peerp;
char *peername;
int sockfd=0;
int
udp_init(void/*char *peername*/)
{
sendbuf=(char *)malloc(sizeof(udp2sipmsg.buf[MAXLINE]));
recvbuf=(char *)malloc(sizeof(udp2sipmsg.buf[MAXLINE]));
bzero(sendbuf,sizeof(udp2sipmsg.buf[MAXLINE]));
bzero(recvbuf,sizeof(udp2sipmsg.buf[MAXLINE]));
sockfd=socket(AF_INET,SOCK_DGRAM,0);
if(sockfd <=0)
perror("socket error");
printf("sockfd=%d",sockfd);
int optval = 1;
setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (char *)&optval, sizeof(optval));
char *peername="heyunping";
if((peerp=gethostbyname(peername))==NULL)
perror("getpeerbyname error");
相关问答:
写了个测试程序如下
struct hostent *hp;
char AlarmDevIP[20];
int x2;
hp = gethostbyname("www.google.com");
if (hp)
{
......
引用内容vsking 2009-12-25 22:56:52
现在是win2008和iis8的时代了,不要还停留在iis5时代,win2008被评为十佳操作系统之首不是偶然的,你要是..
我的问题是:
最近想买个服务器,看了dell上的系统定制选择,一些 ......
我的板子用嵌入式linux系统发送组播包给我PC虚拟机的linux,虚拟机的linux可以接收到,但是同样的程序,用虚拟机的linux发送,嵌入式linux却接收不到,具体表现为阻塞在recvfrom函数。
大致已经可以排除的问题:
1 ......
各位大虾,先问声好!
想请教一下在window下用putty怎么部署linux服务器上的SSH框架,数据库和tomcat都安装好了,jdk也装上去了,现在就是怎么在上面搭建SSH框架了!求各位不吝赐教!或者提供相应 ......
我买了一个独立服务器 有固定IP 并且域名也已经解析到相应的IP上了
通过F-Secure SSH 也已经连上服务器 关键不会让服务器绑定上相应的域名 没法访问
也通过网上相关教程试了 可是没用 其中一个相对全一点的教程
h ......