• Post Reply Bookmark Topic Watch Topic
  • New Topic

About the Socket connection

 
hotsoup
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Help!
I used a client socket(java) to connect with a server socket
(VC).I sended a package to server,and when I recieved the ackage ,an error appeared.
"java.netSocketException:JVM_recv in socket input stream read (code=10053)".
I know that it's because of serversocket closing.But I
don't know how to resolve it.
Help!
Thanks a lot.
hotsoup
------------------
 
Dragon Liu
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi hotsoup:
If you have the source code of ServerSocket,you can see when the
Serversocket receive your request datagram,what does it deal with
it.Maybe The ServerSocket close right now without send data to you when receive your datagram.
In vc the socket is more complex than socket in java.
 
hotsoup
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dragon Liu:
Hi hotsoup:
If you have the source code of ServerSocket,you can see when the
Serversocket receive your request datagram,what does it deal with
it.Maybe The ServerSocket close right now without send data to you when receive your datagram.
In vc the socket is more complex than socket in java.

In fact,the serversocket has send the data to me.And when I use
Delphi or VB as the clientsocket,I can get the data from the serversocket.No problem!
So I don't think the serversocket is wrong.I can give you my source code , check it please!Thank you.
Importance:"client_in.read(cbuf)"
public class H2Sock
{
private BufferedReader client_in ;
private PrintStream client_out;
private Socket sock;
//
public H2Sock(){
try{
sock = new Socket("redhat",8009);
sock.setSoTimeout(5000);
DataOutputStream cl_out= new DataOutputStream(sock.getOutputStream());
client_out=new PrintStream(cl_out);
client_in = new BufferedReader(new InputStreamReader(sock.getInputStream()));
}catch(Exception e)
{
System.out.println("Error:"+e);
}
}
//
public H2Sock(String host,int port){
try{
sock = new Socket(host,port);
sock.setSoTimeout(5000);
DataOutputStream cl_out= new DataOutputStream(sock.getOutputStream());
client_out=new PrintStream(cl_out);
client_in = new BufferedReader(new InputStreamReader(sock.getInputStream()));
}catch(Exception e)
{
System.out.println("Error:"+e);
}
}
public void Send(String sendStr)
{
try{
String overFlag = "\u001a";
String sendPackage = sendStr + overFlag;
client_out.println(sendPackage);
client_out.flush();
System.out.println("SendSuccess!");
}catch(Exception e){
System.out.println("SendError:"+e);
}
}
public Vector Accept()
{
String result = "";
Vector resultBuf = new Vector();
char cbuf[] = new char[20480];
try{
client_in.read(cbuf);
int bufLen = lenOfbuf(cbuf);
System.out.println("Length :"+bufLen);
boolean more = true;
int index = 0;
while(more)
{
result = result + cbuf[index];
if(index == bufLen-1)
more = false;
if(index == 79){
resultBuf.add(result);
result = "";
}
index ++;
}
resultBuf.add(result);
}catch(Exception e){
System.out.println("AcceptError:"+e);
}
return resultBuf;
}
}

 
shailesh sonavadekar
Ranch Hand
Posts: 1874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hotsoup , Welcome to javaranch.
PROPER NAMES ARE NOW REQUIRED
Please look carefully at official naming policy at javaranch & reregister yourself with proper first & last name. Please adhere to official naming policy & help maintain the decorum of the forum.
Waiting for your posts with proper first & last name. Once you have reregister , please let us know about that & then your previous account will be disabled.
Regards.

Your Friendly Bartender
Shailesh.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!