B
B
Bartar2016-09-24 22:00:48
Java
Bartar, 2016-09-24 22:00:48

How is data transmitted via socket?

As I understand it, to connect to the server using a socket, you just need to create it, but what if the program transmits different data at the same time, such as voice and text? It turns out that 2 class sockets are created, which are connected to one server?
ps I apologize if the question is stupid and all that, but this topic is very interesting to me.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
1
15432, 2016-09-24
@15432

Implementation dependent. You can send everything through one socket. Establish a TCP connection, send a packet header specifying the type of data (voice or text) and the size of the data, then transmit the data itself.
On the other hand, the server will receive the header, see how much data to receive after it, receive the data itself and wait for a new header.

O
Oleg Tsilyurik, 2016-09-24
@Olej

How is data transmitted via socket?

In the same way as through a file descriptor, a socket is an extension of the concept of a file descriptor: you can write (read) anything there (from there) (this is a byte stream), and parsing the nature of the information in the stream is already the task of your specific project.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question