This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/MSP432E401Y: Create TCP Connection between MSP432E401Y(Client) and PC(Server)

Part Number: MSP432E401Y

Tool/software: Code Composer Studio

Hello,

I want my MSP432E401Y to work as a client and connect to the PC. In the example tcpecho, although a connection is established with the PC, the microcontroller waits (accept ()) for a request. I want the microcontroller to send the connection request (connect ()).

I did the following but unfortunately it does not work. what am I doing wrong?

regards,

Fares

/*
* ======== tcpHandler ========
* Creates new Task to handle new TCP connections.
*/
void tcpHandler(uint32_t arg0, uint32_t arg1)
{
void *thread = NULL;
int status;
int server;
struct sockaddr_in clientAddr;
int optval;
int optlen = sizeof(optval);
socklen_t addrlen = sizeof(clientAddr);


Display_printf(displayOut, 0, 0, "TCP Echo example started\n");


bzero(&server, addrlen);
clientAddr.sin_family = AF_INET;
clientAddr.sin_addr.s_addr = INADDR_ANY;
clientAddr.sin_port = htons(arg0);

server = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (server == -1) {
Display_printf(displayOut, 0, 0, "tcpHandler: socket failed\n");
goto shutdown;
}
optval = 1;
setsockopt(server, SOL_SOCKET, SO_REUSEADDR, (char *) &optval,
optlen);

status =connect(server, (struct sockaddr *)&clientAddr, addrlen);
if (status == -1) {
Display_printf(displayOut, 0, 0, " network:tcp Error in connect\n");
goto shutdown;
}

  • Hello Fares,

    This post looks like a duplicate the below mentioned post. I have already provided a response to the below mentioned post, so I will close this post. e2e.ti.com/.../2690695

    In the future, if possible, please avoid posting multiple threads on the same topic as this increases the delaying in providing responses to all posts.

    Thanks,
    Sai

**Attention** This is a public forum