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.
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;
}
Hello Fares,
Fares Rabuts said:Is there an example where the MSP432E works as a server?
The "tcpecho" example in the SimpleLink MSP432E4 SDK (in the folder ./examples/rtos/MSP_EXP432E401Y/ns/tcpecho) already acts as a TCP server. The accompanying python script "tcpSendReceive.py" (in the folder ./tools/examples/) works as a TCP client.
Fares Rabuts said:Although I managed to establish a connection, but the PC is the connection.
Do you mean that the PC joined the TCP network that the MSP432E4 has created? This is the default behavior of the "tcpecho" example and the accompanying python script "tcpSendReceive.py".
Fares Rabuts said:But I want to build the microcontroller of this connection.
Do you mean that you want the MSP432E4 device to join a TCP network that a PC creates? If so you will have to inverse the behavior. The python script should act as a TCP server and the MSP432E4 should act as a TCP client.
We currently don't have examples in the SimpleLink SDK for this behavior, but looking at the "tcpecho" example and the accompanying python script "tcpSendReceive.py", I believe you should have a good starting point to achieve this behavior. The Simplelink MSP432E4 SDK supports BSD sockets so any example that uses BSD sockets can be ported to this SDK.
Hope this helps!
Thanks,
Sai
**Attention** This is a public forum