23,124
社区成员
发帖
与我相关
我的任务
分享
for(;;)
{
int confd=accept(listenfd,NULL,NULL);
struct iovec io[2];
int temp=2 ;
char *ch="luoxiongwei";
io[0].iov_base=ch;
io[0].iov_len=strlen(ch)+1;
io[1].iov_base=&temp;
io[1].iov_len=4;
writev(confd,io,2);
close(confd);
}
struct iovec io[2];
char ch [20];
memset(ch,'\0',20);
int temp ;
io[0].iov_base=ch;
io[0].iov_len=20;
io[1].iov_base=&temp;
io[1].iov_len=4;
readv(handle_fd,io,2);
close(handle_fd);
cout<<"ch="<<ch<<endl;
cout<<"temp="<<temp<<endl;
struct iovec io[2];
char ch [20];
memset(ch,'\0',20);
int temp ;
io[0].iov_base=ch;
io[0].iov_len=20;
io[1].iov_base=&temp;
io[1].iov_len=4;
readv(handle_fd,io,2);
close(handle_fd);
cout<<"ch="<<ch<<endl;
cout<<"temp="<<temp<<endl;
for(;;)
{
int confd=accept(listenfd,NULL,NULL);
struct iovec io[2];
int temp=2 ;
char *ch="luoxiongwei";
char ch_int [2];
memset(ch_int,'\0',2);
sprintf(ch_int,"%d",temp);
io[0].iov_base=ch;
io[0].iov_len=strlen(ch)+1;
io[1].iov_base=ch_int;
io[1].iov_len=strlen(ch_int)+1;
writev(confd,io,2);
close(confd);
}
struct iovec io[2];
char ch [20];
memset(ch,'\0',20);
char buffer [2];
memset(buffer,'\0',2);
io[0].iov_base=ch;
io[0].iov_len=12;
io[1].iov_base=buffer;
io[1].iov_len=2;
readv(handle_fd,io,2);
close(handle_fd);
cout<<"ch="<<ch<<endl;
cout<<"temp="<<atoi(buffer)<<endl;
#define UIO_MAXIOV 1024
/* Structure for scatter/gather I/O. */
struct iovec
{
void *iov_base; /* Pointer to data. */
size_t iov_len; /* Length of data. */
};
#endif