sorry if this is silly question . after many hour searching on internet , i am not clear how it works .
example : the server on windows was coded with c++ using socket (winsock) ,
the client is ios application and was coded with objective c (using bsd socket )
when client send a request to server , does the server accept the request normally ??? and does i need to do something more or i only deal with logic server and client .
-- low level socket will only send and receive raw struct , is the struct of c++ ( for network packet i only use basic c struct not c++ struct ) like struct of objective c
client can accept this c++ struct and read data from it ???
if it not possible , how client and server on different os can send and receive
each other packet .
example android os , client was used low level network java api and c++ wrapper code use this through jni call , but still need send and receive struct between java and c++
can anyone elaborate this matter for beginner please
(sorry english is not my native , so i cant express this detail , correct me if i am wrong )
Only bytes (not structs or anything alike) are transfered with sockets. Client and server are able to communicate when both using the same protocol. That's it. The language or system is irrelevant.
thanks for your reply , as you write , struct is block of byte and java or any language can get this block (same tcp ip or udp ) and if we take care of language specification like struct pad or space .... we can get the data from this block .
if we take care of language specification like struct pad or space .... we can get the data from this block
While this is theoretically true it is not worth the effort and not recommended.
By the way:
You cannot use complex data types that contains pointer(s) such as std::string or any other standard container. Because you would transmit the pointer not the data pointed to.
You have to be careful with numeric variables as well due to the endianness / byte order: