LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 612|回复: 3

关于socket编程的问题

[复制链接]
发表于 2006-4-21 15:03:58 | 显示全部楼层 |阅读模式
请问:怎么能实现当一个客户端连接服务器后,其他客户端不能再连接服务器同个端口???

listen函数中有个backlog,好像设成1也不行!!!
发表于 2006-4-22 02:34:57 | 显示全部楼层
backlog is OS-specific .  In general , the actual number of queued connections does not equal to backlog.  you can consult UNIX network programming API volume 2;

after invokeing accpet() at server-end, u  close the file-descriptor in listen() ,  now,others couldn't establish TCP connections with the port;
回复 支持 反对

使用道具 举报

发表于 2006-4-22 02:38:51 | 显示全部楼层
sorry , it should be UNIX network programming API volume 1
回复 支持 反对

使用道具 举报

发表于 2006-4-22 11:33:12 | 显示全部楼层
只要服务器是单线程或单进程的,就可以做到一次只响应一个连接。至于要限制不能再连接某个端口,似乎没有这个必要吧。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表