6 years, 9 months ago.

TCP Socket Client for Java

Hey everybody!

I've written a java application which corresponds with the mbed. I created a HttpServer on the Mbed and used RPC Variables to set variables on the mbed. What I now want to do is a TCP Socket connection, in which the mbed will be the client and the pc with the java application the Server. I already succesfull created client/server in java and was able to connect and send/receive data.

But I'm lost in writting a TCP Client on the mbed. I used the Example from Roy van Dam: http://mbed.org/users/NegativeBlack/code/NetworkAPI/wiki/tcp-client-example . which didn't work. Now I am trying a very basic client programm to connect to the socket which i took from Socket handbook and it looks like this:

#include "mbed.h"
#include "EthernetInterface.h"

static const char*          mbedIp       = "";  //IP
static const char*          mbedMask     = "";  // Mask
static const char*          mbedGateway  = "";    //Gateway
static const char*          pcIp         = "";
static int port = 1234;

    EthernetInterface interface;
    interface.init(mbedIp, mbedMask, mbedGateway);
    printf("IP Address is %s\n\r", interface.getIPAddress());
    TCPSocketConnection connection;
    while(connection.connect(pcIp, port) <0){
        printf("Unable to connect to socket!");

But its also not possible to connect to the java Server....

Am I missing something? Or does someone have a very simple/basic implementation of a java server / mbed socket client?

Thanks in advance & Best Regards Michael

Question relating to:

Be the first to answer this question.