由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - socket re-connection problem
相关主题
C10M 练习2: 空TCP 连接,1M per 4G RAMHelp: Socket.SendFile() cannot be recognized by c# compiler
有没有人在Vista下试过UDP广播两道小题
unix network programming (Stevens) book V1 (2ed, 3ed) code cannot run on Linux初级socket问题
一个socket中select函数的问题Linux Socket编程
问一个Linux无法监听指定端口的问题问个关于socket问题
python question: A socket operation was attempted to an unreachable networkUDP广播老是接收不到
服务器测试结果问个socket close的问题
想编一个从同一台机器上的很多虚拟IP地址发出packet的程序?An interview project: asynchronous socket programming
相关话题的讨论汇总
话题: socket话题: bind话题: problem话题: connection
进入Programming版参与讨论
1 (共1页)
mw
发帖数: 525
1
Now i have a TCP/IP, server program. It uses its ip address and port number to
bind a socket ,then listen and connect.
The problem is , after the client side is shutdown, it needs to re-connect.
But after I "closesocket", how can i re-setup this connection ?
My process is "open socket again" ->setsockopt->bind, but the "bind" just
fails and complains that the port is in use. Wierd! I have already shutdown
the socket use "closesocket", there should not be such problem at all...
can anyone help?
t
m*****e
发帖数: 4193
2

You don't close the socket bind() returns. You close the one accept()
returns. And if you do this way, of course you cannot bind() it again.

【在 mw 的大作中提到】
: Now i have a TCP/IP, server program. It uses its ip address and port number to
: bind a socket ,then listen and connect.
: The problem is , after the client side is shutdown, it needs to re-connect.
: But after I "closesocket", how can i re-setup this connection ?
: My process is "open socket again" ->setsockopt->bind, but the "bind" just
: fails and complains that the port is in use. Wierd! I have already shutdown
: the socket use "closesocket", there should not be such problem at all...
: can anyone help?
: t

mw
发帖数: 525
3
yi ju hua dian xing meng zhong ren
i really appreciate your immediate help!thanks alot!

number to
re-connect.
shutdown

【在 m*****e 的大作中提到】
:
: You don't close the socket bind() returns. You close the one accept()
: returns. And if you do this way, of course you cannot bind() it again.

m*******n
发帖数: 103
4
我也正在写一个TCP程序。
你是怎么知道一个函数需要哪个lib的。例如,socket 使用 socket lib.但是,writen
,readline 使用的是什么lib
本人仍然没有链接成功。:-(

just

【在 mw 的大作中提到】
: yi ju hua dian xing meng zhong ren
: i really appreciate your immediate help!thanks alot!
:
: number to
: re-connect.
: shutdown

c********e
发帖数: 383
5
dont quite understand what you said ....but if you are binding the client
program who is doing the connect call, 1. you dont have to you can use the
em..port that the kernal gives you. INET_ANY 2, there is a socket option to
make the socket reusable check man page for setsockopt. this is usually for
sockets in the waiting state.

【在 mw 的大作中提到】
: Now i have a TCP/IP, server program. It uses its ip address and port number to
: bind a socket ,then listen and connect.
: The problem is , after the client side is shutdown, it needs to re-connect.
: But after I "closesocket", how can i re-setup this connection ?
: My process is "open socket again" ->setsockopt->bind, but the "bind" just
: fails and complains that the port is in use. Wierd! I have already shutdown
: the socket use "closesocket", there should not be such problem at all...
: can anyone help?
: t

l*l
发帖数: 26
6
man socket
man writen
man readline

【在 m*******n 的大作中提到】
: 我也正在写一个TCP程序。
: 你是怎么知道一个函数需要哪个lib的。例如,socket 使用 socket lib.但是,writen
: ,readline 使用的是什么lib
: 本人仍然没有链接成功。:-(
:
: just

1 (共1页)
进入Programming版参与讨论
相关主题
An interview project: asynchronous socket programming问一个Linux无法监听指定端口的问题
C++网络编程问题python question: A socket operation was attempted to an unreachable network
求建议:C++的TCP/IP编程库服务器测试结果
Socket accept failed - WSAEMFILE想编一个从同一台机器上的很多虚拟IP地址发出packet的程序?
C10M 练习2: 空TCP 连接,1M per 4G RAMHelp: Socket.SendFile() cannot be recognized by c# compiler
有没有人在Vista下试过UDP广播两道小题
unix network programming (Stevens) book V1 (2ed, 3ed) code cannot run on Linux初级socket问题
一个socket中select函数的问题Linux Socket编程
相关话题的讨论汇总
话题: socket话题: bind话题: problem话题: connection