tcpShutdownOutput()

Closes the write direction of a TCP socket.

Synopsis

int tcpShutdownOutput(int socket);

Parameters

Parameter Description
socket Number of the socket

Return value

0 if the function was executed successfully, otherwise -1.

Error

Missing or wrong arguments.

Description

A connection to a HTTP server is established via the tcpOpen() function. Data is written on the socket via the tcpWrite() function. The write direction is closed using the tcpShutdownOutput() function. When the direction is closed, the tcpWrite() function cannot be used anymore.

When the tcpShutdownOutput() is executed, tcpRead can still read the socket once!

Example

main()
{
string computerNam= "eitst013xp", data;
unsigned Portnumb= 125;
int socket, modWrite, modClose, modRead;
time t = 10;

//Open-> Write-> Close
socket = tcpOpen(computerNam, Portnumb);
DebugN("Open: " + socket + computerNam+ Portnumb);
DebugN("Delay");
delay(5);

//Write
modWrite= tcpWrite(socket, "TEST");
DebugN("Write: " + modWrite);
DebugN("Delay");
delay(5);

//Close
modClose= tcpShutdownOutput(socket);
DebugN("ShutdownOutput: " + modClose);
DebugN("Delay");
delay(5);

//try to write again. Writing does not work anymore
modWrite= tcpWrite(socket, "WRITING DOES NOT WORK ANYMORE");
DebugN("Write does not work anymore: " + modWrite);
DebugN("Delay");
delay(5);

modRead = tcpRead(socket, data, t);
DebugN("Read: " + modRead);
DebugN("Read data: " + data);
DebugN("Finish");
}

Assignment

Communication functions

Availability

CTRL