About Store Forum Documentation Contact



Post Reply 
Sending and receiving "File" over a socket
Author Message
Babulesnik Offline
Member

Post: #1
Sending and receiving "File" over a socket
Really need to send or receive "File" in the socket. Since it is implemented in the "Connection"
PHP Code:
Bool dataFull (File fInt sizeBool send true); 
10-12-2011 11:57 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Sending and receiving "File" over a socket
you can do it manually, using Memc<Byte>, File::put, get

I recommend that you use Connection (TCP/IP) or FastConnection (UDP) which have File based methods
10-12-2011 12:34 PM
Find all posts by this user Quote this message in a reply
Babulesnik Offline
Member

Post: #3
RE: Sending and receiving "File" over a socket
Thanks I will try to use "FastConnection" . I have long been using "Connection" to connections of the client / server. But I need to transfer data between the clients client/client. I do it for unloading the server and wanted to implement it through sockets.
10-12-2011 12:44 PM
Find all posts by this user Quote this message in a reply
Babulesnik Offline
Member

Post: #4
RE: Sending and receiving "File" over a socket
FastConnection only takes a sequence of values ​​of type "Byte"
Code:
Int receive(SockAddr &addr, Byte (&data)[65536]);
How to do it would take "Str" and "Byte or Int" simultaneously ?.How it is implemented in "Connection".
10-13-2011 08:46 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #5
RE: Sending and receiving "File" over a socket
File::readMem, look into headers more carefully
10-13-2011 09:05 PM
Find all posts by this user Quote this message in a reply
Babulesnik Offline
Member

Post: #6
RE: Sending and receiving "File" over a socket
(10-13-2011 09:05 PM)Esenthel Wrote:  File::readMem, look into headers more carefully
Thank you. It's bad for me -> "order of received data is not guaranteed to be the same as when sending". How to use the Connection at the same time to communicate with the server and exchange between clients?

I use the "Connection" to connect a client / server - it works perfectly !.But how can I use this class to be used between clients if it is set once Bool clientConnectToServer(C SockAddr &server_addr); ?


I need some frequently transmit the position of some items, status of players in the "playroom" and other not very important data. I do not want to send them through the server to other players. I want to exchange the data between clients. It will not load the server. For example: WorldOfTanks on a single server supports 200 000 (200k!) players online
(This post was last modified: 10-13-2011 10:16 PM by Babulesnik.)
10-13-2011 10:06 PM
Find all posts by this user Quote this message in a reply
Babulesnik Offline
Member

Post: #7
RE: Sending and receiving "File" over a socket
Who knows how this can be done?
10-14-2011 05:23 PM
Find all posts by this user Quote this message in a reply
Sadahar Offline
Member

Post: #8
RE: Sending and receiving "File" over a socket
Over TCP/IP (Connection) the received data order IS guaranteed.
Just put that byte array you received into a File object

Code:
File filebuffer; // SIZE is 1024.
filebuffer.writeMem();

Byte buffer[1024];

Int count = socket.receive(buffer, SIZE(buffer));
for (int i = 0; i < count; i++)    filebuffer << buffer[i];

And there you have your data in the file as you received it.
Im not sure if that code works, I just arranged a little piece of mine's... Im not using Connection, but Socket, with a custom NetMgr class...

Also in TCP consider that if you send 2 pkts at the same time.. if they are small enought they will be merged into one.
10-16-2011 01:35 PM
Find all posts by this user Quote this message in a reply
Babulesnik Offline
Member

Post: #9
RE: Sending and receiving "File" over a socket
(10-16-2011 01:35 PM)Sadahar Wrote:  Over TCP/IP (Connection) the received data order IS guaranteed.
Just put that byte array you received into a File object

Code:
File filebuffer; // SIZE is 1024.
filebuffer.writeMem();

Byte buffer[1024];

Int count = socket.receive(buffer, SIZE(buffer));
for (int i = 0; i < count; i++)    filebuffer << buffer[i];

And there you have your data in the file as you received it.
Im not sure if that code works, I just arranged a little piece of mine's... Im not using Connection, but Socket, with a custom NetMgr class...

Also in TCP consider that if you send 2 pkts at the same time.. if they are small enought they will be merged into one.
Thank you very much.
10-16-2011 02:30 PM
Find all posts by this user Quote this message in a reply
Post Reply