Redian新闻
>
求教!请教client & server program. 感激涕零
avatar
求教!请教client & server program. 感激涕零# Unix - 噫吁兮,危乎高哉
b*r
1
不知道为什么client在二次read的时候,返回值会是-1,它应该是0才对。
谢谢。
./server&
./client username
>>hello
/*server program
run as ./server &
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define MAXHOSTNAME 32
#define PORT 1550
#define SPACE " "
void *manage_client (void *argp);
/*
ABOUT ME
++++++++
I am a sample server, who handles messages from only one client.
I read com
avatar
a*n
2
where is your read in the client?

【在 b******r 的大作中提到】
: 不知道为什么client在二次read的时候,返回值会是-1,它应该是0才对。
: 谢谢。
: ./server&
: ./client username
: >>hello
: /*server program
: run as ./server &
: */
: #include
: #include

avatar
b*r
3
I reassign the value of t
in while loop of client funtion
by t=int(*argv) every loop,
then it works.
seem t becomes 0 after each loop
why?
I use recv for "read"
Thank

【在 a***n 的大作中提到】
: where is your read in the client?
avatar
n*t
4
actually, very simple.
You should not share t among different threads.

【在 b******r 的大作中提到】
: I reassign the value of t
: in while loop of client funtion
: by t=int(*argv) every loop,
: then it works.
: seem t becomes 0 after each loop
: why?
: I use recv for "read"
: Thank

avatar
f*k
5
oh, netghost, it seems I made the same mistake.

【在 n******t 的大作中提到】
: actually, very simple.
: You should not share t among different threads.

avatar
n*t
6
hehe

oh, netghost, it seems I made the same mistake.

【在 f******k 的大作中提到】
: oh, netghost, it seems I made the same mistake.
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。