aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes Problem sending string over TCP - String is split into two parts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Problem sending string over TCP - String is split into two parts" Watch "Problem sending string over TCP - String is split into two parts" New topic
Author

Problem sending string over TCP - String is split into two parts

Bjorn Christian Sebak
Greenhorn

Joined: May 07, 2012
Posts: 1
I have written a service that connects to a remove server using simple Java Sockets in order to retrieve some XML data. I am requried by the remove server to set up a simple Socket connection, and send a login string containing my username and password, before I start receiving data back from the remote server. The login string is on the format "login:myusername:mypassword". The problem is that the remote server gets the login string in two chunks (like "login:us" and "ername:mypassword", where the string is split seem to be pretty random), which means the authentication fails and I dont get any data back over the socket. I cannot for the life of me figure out why this is so.

I have tried other ways of connecting (using a Python script), which works fine. It seem to be a Java-issue for some reason.

Here is a bare-bone example of my code:



The server runs though a Solaris machine. Maybe that is the issue?

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem sending string over TCP - String is split into two parts