1. UDP sendto and recvfrom

Have sendto and recvfrom been remover from the sockel lib? The are needed to support UDP.

new topic     » topic index » view message » categorize

2. Re: UDP senttp and recvfrom

elias1 said...

Have sendto and recvfrom been remover from the sockel lib? The are needed to support UDP.

Hm. Not intentionally! I'll work on putting them in. This must have taken place when the code was moved from a Euphoria include file into the C backend of Euphoria.

Sorry about that!

Jeremy

new topic     » goto parent     » topic index » view message » categorize

3. Re: UDP senttp and recvfrom

Thank for the quick response. I use usp for debug and monitoring test applications.

Elias

new topic     » goto parent     » topic index » view message » categorize

4. Re: UDP sendto and recvfrom

elias1 said...

Have sendto and recvfrom been remover from the sockel lib? The are needed to support UDP.

elias1, could I beg you for an example? Something small that would have a server and client and could be put in the demo directory?

I am about done adding both sendto and recvfrom to Euphoria. It would help greatly to have something to test with. I know you will not be able to test the code, but I could work out any bugs.

Jeremy

new topic     » goto parent     » topic index » view message » categorize

5. Re: UDP sendto and recvfrom

elias1,

send_to and receive_from are now in Euphoria, however, they are 100% untested. I've not done anything with UDP in the past. If you are running from a SVN copy of Euphoria, you can test them. You can grab an eubin of 2618 or later but you will also need the update include/std/socket.e to make it work.

eubins are located at: http://jeremy.cowgar.com/eubins/

Jeremy

new topic     » goto parent     » topic index » view message » categorize

6. Re: UDP sendto and recvfrom

elias1,

OK, UDP functions send_to and receive from are added and tested. Two examples were added, udp_client.ex and udp_server.ex, to the demo directory. These will be deployed with 4.0b2 which should be released tomorrow.

udp_server.ex:

include std/socket.e as sock 
 
sock:socket server = sock:create(sock:AF_INET, sock:SOCK_DGRAM, 0) 
integer result = sock:bind(server, "0.0.0.0:27015") 
 
puts(1, "Waiting for a client connection on port 27015\n") 
object o = sock:receive_from(server) 
if sequence(o) then 
    printf(1, "From: %s:%d, '%s'\n", o) 
else 
	printf(1, "Error code: %d\n", { o }) 
end if 
 
sock:close(server) 


udp_client.ex

include std/socket.e as sock 
 
sock:socket client = sock:create(sock:AF_INET, sock:SOCK_DGRAM, 0) 
sock:set_option(client, sock:SOL_SOCKET, SO_BROADCAST, 1) 
 
integer result = sock:send_to(client, "Hello World!", "127.0.0.1", 27015) 
if result > 0 then 
    printf(1, "Sent %d bytes\n", { result }) 
else 
	printf(1, "Error code: %d\n", { result }) 
end if 
 
sock:close(client) 


How do those look?

Jeremy

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu