About Store Forum Documentation Contact
Donations:
327$/mo



Post Reply 
problem with sockets
Author Message
Babulesnik Offline
Member

Post: #1
problem with sockets
If I start to betray and take "Str" a program that takes is crashes.

If I use a "Byte" type are normally

PHP Code:
for(SockAddr addr;;)
    {
        
Str  Buffer;
        
Int  rcv=MySocketUDP.receive(addr , &BufferSIZE(Buffer)); 
        if(  
rcv<0)break;

        
ReceiveStr Buffer;
    } 
10-08-2011 09:03 PM
Find all posts by this user Quote this message in a reply
Babulesnik Offline
Member

Post: #2
RE: problem with sockets
How to send and receive file over a socket ? This code generates an crashed when receiving data (((
PHP Code:
Bool Update() 
{
    
Gui.update();

    
// send
    
if(Kb.bp(KB_SPACE))
    {
        
File f;f.writeMem().putStr("Hello!").pos(0);
        
SockAddr addr;

        
addr.fromText(S+"127.0.0.1:"+LinePort()() );
        
MySocketUDP.send(addr, &fSIZE(f));
    }
    
// receive
    
for(SockAddr addr;;)
    {
        
File f;
        
Int  rcv=MySocketUDP.receive(addr , &fSIZE(f)); 
        if(  
rcv<0)break;

        
ReceiveStr f.getStr();
    } 
10-09-2011 08:46 PM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #3
RE: problem with sockets
Perhaps you need to send the size of the file first, then send the file. Then, receive the size of the file first and use that instead of SIZE(f) when receiving the actual file.
10-10-2011 02:16 AM
Find all posts by this user Quote this message in a reply
Post Reply