Re: Create new socket

new topic     » goto parent     » topic index » view thread      » older message » newer message
jeremy said...

socket s = create() 
if atom(s) then 
    printf(1, "Could not create socket, error number: %d\n", { s }) 
end if 

Or:

socket s = create() 
if not valid(s) then -- a sockets.e function to validate your socket* 
   printf(1, "Error %d:%s", { get_error_num( s ), get_error_msg( s ) }) -- sockets.e error management 
-- or 
   printf(1, "Error %d:%s", get_error(s) ) -- or get_error() could return {errnum,errmsg} 
-- or 
   printf(1, "Error %d:%s", s[2] ) -- on fail, s is {0,{errnum,errmsg}} 
else 
   -- process normally 
end if 
-- in sockets.e 
public function valid(object s) 
   return sequence(s) and length(s) > 0 and s[1] -- hopefully this short-circuits... smile 
end function 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu