Tool/software: Code Composer Studio
Hello,
I'm trying to establish a TCP connection between the MSP432E and my PC. Although I managed to establish a connection, but the PC is the connection. But I want to build the microcontroller of this connection. I entered into the TCPHandler this: (So approximately the accept function with connect function replaced) but that does NOT work.
Is there an example where the MSP432E works as a server?
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;
}