diff --git a/fvtest/porttest/omrsockTest.cpp b/fvtest/porttest/omrsockTest.cpp index e08da489d3e..14de348ee77 100644 --- a/fvtest/porttest/omrsockTest.cpp +++ b/fvtest/porttest/omrsockTest.cpp @@ -510,6 +510,41 @@ TEST(PortSockTest, two_socket_stream_communication) omrsock_socket_t connectedClientStreamSocket = NULL; EXPECT_EQ(OMRPORTLIB->sock_accept(OMRPORTLIB, serverStreamSocket, &connectedClientStreamSockAddr, &connectedClientStreamSocket), 0); + char msg[100] = "This is an omrsock test for 2 socket stream communications."; + int32_t bytesLeft = strlen(msg) + 1; + uint8_t *cursor = (uint8_t *)msg; + int32_t bytesSent = 0; + while(1){ + bytesSent = OMRPORTLIB->sock_send(OMRPORTLIB, connectedClientStreamSocket, cursor, bytesLeft, 0); + if (bytesSent < 0) { + FAIL(); + break; + } + bytesLeft -= bytesSent; + cursor += bytesSent; + if(0 == bytesLeft) { + break; + } + } + + char buf[100] = ""; + bytesLeft = strlen(msg) + 1; + cursor = (uint8_t *)buf; + int32_t bytesRecv = 0; + while(1) { + bytesRecv = OMRPORTLIB->sock_recv(OMRPORTLIB, clientStreamSocket, cursor, bytesLeft, 0); + if (bytesRecv < 0) { + FAIL(); + break; + } + bytesLeft -= bytesRecv; + cursor += bytesRecv; + if (0 == bytesLeft) { + break; + } + } + EXPECT_EQ(strcmp(msg, buf), 0); + EXPECT_EQ(OMRPORTLIB->sock_close(OMRPORTLIB, &connectedClientStreamSocket), 0); EXPECT_EQ(OMRPORTLIB->sock_close(OMRPORTLIB, &clientStreamSocket), 0); EXPECT_EQ(OMRPORTLIB->sock_close(OMRPORTLIB, &serverStreamSocket), 0);