1

When establishing a socket in order to achieve client/server communication socket is initialized at the client and at the server side. The way I understand this is that they have 1 FIFO bidirectional file. Now as far as I understood sockets, it means 1 input stream and 1 output stream of a single file, meaning if client is writing to its serverSocket.outputStream let's say, does it mean that server can't at the same time write to clientSocket.outputStream. Is serverSocket.outputStream and clientSocket.outputStream the same FIFO file or is it constructing 2 FIFO files, 1 for client and 1 for server meaning that clientSocket.outputStream and clientSocket.inputStream refer to different FIFO files. It came to be confusing since both streams refer to the same socket within a program and than I intuitively think it needs to be the same file, meaning that there is possibly a conflict if clientSocket.outputStream and serverSocket.outputStream write to this file at the same time. Could please someone help and clarify this? I wasn't able to understand it. Am I missing understanding of some underlaying important concept and if so which one?

  • None of this make any sense to me. There are *no* files involved at all, at least as far as the programmer is concerned. There is no difficulty at all with both the server and the client of a socket pair writing at the same time. In fact both the client and the server may both be reading and writing at the same time, so there are 2 read and 2 writes occurring simultaneously, providing the platform supports the appropriate concurrency features. – President James K. Polk May 02 '22 at 20:19

0 Answers0