建立ObjectInputstream对象时程序挂起问题

问题出现:使用socket编程,客户端在执行建立objectinputstream对象时程序挂起,但不报错!
问题原因:建立objectinputstream对象是需要先接收一定的header数据,接收到这些数据之前会处于阻塞状态
java api文件的说明
creates an objectinputstream that reads from the specified inputstream. a serialization stream header is read from the stream and verified. this constructor will block until the corresponding objectoutputstream has written and flushed the header.
问题解决:服务器发送一个object后,客户端objectinputstream对象便可建立!

你可能感兴趣的:(编程,socket)