Problems Connecting Via TCP

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

Problems Connecting Via TCP

Postby blackraven36 » Fri Apr 13, 2012 5:41 am

I am unfortunately having a problem connecting to a TCP server I put together. The server is fairly sophisticated but the connection, disconnection and data transition protocols are fairly simple. The server has been tested by a number of different clients both written in Java and C#. The server itself runs on C# using the standard Microsoft TCPClient and TcpListener classes in order to facilitate connection. I cant say much about what the TCP server does, just that there has to be a side which allows connections from peripheral. It is necessary that the server be able to feed data to connected network peripherals running android, including cellphones and tablets.

For testing purposes I am connecting to the current port which handles the current data feed. Nothing is connected to that port, this is a test version of the server which runs separate from the actual production server. I cannot expose to you the server side code unfortunately.

The following code is what is currently running off a cellphone. It should establish a simple TCP connection to the sever after which the server kills the connection due to a failed handshake. The server lets me know if something is connected and whether or not a handshake has gone through. The following code WORKS (network part at least) when executed on a windows machine but fails to establish a connection when utilized on an android phone. Tested with both wifi aswell as the network provided internet.

AddressButton.setOnClickListener(new View.OnClickListener()
{
public void onClick(View view)
{

serverIP = ipAddressTextArea.getText().toString();//we can assume this is a valid IP
messages = Toast.makeText(getApplicationContext(), "Attempting to Connect To Server...", Toast.LENGTH_SHORT);
messages.show();
LittleEndianDataOutputStream writter = null;
Socket testTCPSocket = null;
try {
// TODO code application logic here
testTCPSocket = new Socket(serverIP, *******); //Sorry guys cant provide this information
writter = new LittleEndianDataOutputStream(testTCPSocket.getOutputStream()); //Guava
writter.writeInt(200); //Invalid handshake so server doesn't keep waiting for one
writter.close();

} catch (Exception ex)
{
messages = Toast.makeText(getApplicationContext(), "Attempt Failed...", Toast.LENGTH_SHORT);
messages.show();
}
}
});

I haven't programmed in Java for years and this is my first swing at Android. I am a network programmer coming from C# and C++, so be patient with me on the android side. Remember, this code is a simple test nothing more, so don't yell at me for providing you with code that doesn't do anything.
blackraven36
Freshman
Freshman
 
Posts: 2
Joined: Fri Apr 13, 2012 5:18 am

Top

Re: Problems Connecting Via TCP

Postby blackraven36 » Fri Apr 13, 2012 5:52 pm

BUMP
blackraven36
Freshman
Freshman
 
Posts: 2
Joined: Fri Apr 13, 2012 5:18 am

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 3 guests