当前位置: 技术问答>linux和unix
300分,谁帮我写socket接收这部分,我就给,更多的分也好商量。
来源: 互联网 发布时间:2015-01-11
本文导语: //包的结构: typedef struct _PackHead { short int packsize; short unsigned int packtype; short unsigned int packflag; long datasize; }PackHead; typede...
//包的结构:
typedef struct _PackHead {
short int packsize;
short unsigned int packtype;
short unsigned int packflag;
long datasize;
}PackHead;
typedef struct _RecBuf{
char * buf;
long pbuf;
long totalsize;
char _buf[MAXBUF];
PackHead ph;
}RecBuf;
发送的是一个RecBuf包,接收同样用一个RecBuf结构来接收.
...
RecBuf mybuf;
int isock = accept();
if(isock>0)
{
if((cpid=fork())==0)
{
//后面怎么写?
}
}
typedef struct _PackHead {
short int packsize;
short unsigned int packtype;
short unsigned int packflag;
long datasize;
}PackHead;
typedef struct _RecBuf{
char * buf;
long pbuf;
long totalsize;
char _buf[MAXBUF];
PackHead ph;
}RecBuf;
发送的是一个RecBuf包,接收同样用一个RecBuf结构来接收.
...
RecBuf mybuf;
int isock = accept();
if(isock>0)
{
if((cpid=fork())==0)
{
//后面怎么写?
}
}
|
int ret = read(isock, &mybuf, sizeof(mybuf));