comp.lang.ada
 help / color / mirror / Atom feed
* (Linux) GNAT socket exception - when setting No_Delay
@ 2006-04-13 21:34 AAFellow
  2006-04-14  1:20 ` Robert A Duff
  2006-04-14  9:22 ` Dmitry A. Kazakov
  0 siblings, 2 replies; 12+ messages in thread
From: AAFellow @ 2006-04-13 21:34 UTC (permalink / raw)


Hi Guys,

I'm porting some Ada code from Windows to Linux and I'm getting an
exception that's caused by the code that tries to set the "No_Delay"
option.  This worked fine on windows...is there any reason it doesn't
seem to work on Linux?

I'm trying to research this myself now, but any info or anything you
can do to point me in the right direction would really be appreciated.
Thanks!!




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: (Linux) GNAT socket exception - when setting No_Delay
  2006-04-13 21:34 (Linux) GNAT socket exception - when setting No_Delay AAFellow
@ 2006-04-14  1:20 ` Robert A Duff
  2006-04-17 12:14   ` Alex R. Mosteo
  2006-04-14  9:22 ` Dmitry A. Kazakov
  1 sibling, 1 reply; 12+ messages in thread
From: Robert A Duff @ 2006-04-14  1:20 UTC (permalink / raw)


"AAFellow@hotmail.com" <AAFellow@hotmail.com> writes:

> Hi Guys,
> 
> I'm porting some Ada code from Windows to Linux and I'm getting an
> exception that's caused by the code that tries to set the "No_Delay"
> option.  This worked fine on windows...is there any reason it doesn't
> seem to work on Linux?
> 
> I'm trying to research this myself now, but any info or anything you
> can do to point me in the right direction would really be appreciated.
> Thanks!!

I don't know about this particular case, but I have noticed different
behavior of sockets between windows and linux.  Especially in
error-condition cases.  I don't think that's the fault of the Ada
sockets implementation -- I think the underlying operating systems
just do subtly different things.  I was able to write portable code,
but only by experimenting with both operating systems.  Reading
documentation didn't always help, here (sigh!).

- Bob



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: (Linux) GNAT socket exception - when setting No_Delay
  2006-04-13 21:34 (Linux) GNAT socket exception - when setting No_Delay AAFellow
  2006-04-14  1:20 ` Robert A Duff
@ 2006-04-14  9:22 ` Dmitry A. Kazakov
  1 sibling, 0 replies; 12+ messages in thread
From: Dmitry A. Kazakov @ 2006-04-14  9:22 UTC (permalink / raw)


On 13 Apr 2006 14:34:29 -0700, AAFellow@hotmail.com wrote:

> I'm porting some Ada code from Windows to Linux and I'm getting an
> exception that's caused by the code that tries to set the "No_Delay"
> option.  This worked fine on windows...is there any reason it doesn't
> seem to work on Linux?

I would say that it can't be related to Ada. Check if you are using
setsockopt properly. Maybe the buffer pointer or size is wrong. BOOL might
have different sizes under Windows and Linux, something like that.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: (Linux) GNAT socket exception - when setting No_Delay
  2006-04-14  1:20 ` Robert A Duff
@ 2006-04-17 12:14   ` Alex R. Mosteo
  2006-04-17 14:50     ` AAFellow
  0 siblings, 1 reply; 12+ messages in thread
From: Alex R. Mosteo @ 2006-04-17 12:14 UTC (permalink / raw)


Robert A Duff wrote:
> "AAFellow@hotmail.com" <AAFellow@hotmail.com> writes:
> 
> 
>>Hi Guys,
>>
>>I'm porting some Ada code from Windows to Linux and I'm getting an
>>exception that's caused by the code that tries to set the "No_Delay"
>>option.  This worked fine on windows...is there any reason it doesn't
>>seem to work on Linux?
>>
>>I'm trying to research this myself now, but any info or anything you
>>can do to point me in the right direction would really be appreciated.
>>Thanks!!
> 
> 
> I don't know about this particular case, but I have noticed different
> behavior of sockets between windows and linux.  Especially in
> error-condition cases.  I don't think that's the fault of the Ada
> sockets implementation -- I think the underlying operating systems
> just do subtly different things.  I was able to write portable code,
> but only by experimenting with both operating systems.  Reading
> documentation didn't always help, here (sigh!).

I concur here. When using non blocking sockets, be prepared to get 
different exceptions in windows and in linux. Also detecting if a socket 
connection had succeeded or was still alive was tricky. As Robert wrote, 
it was a matter of having both systems at hand.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: (Linux) GNAT socket exception - when setting No_Delay
  2006-04-17 12:14   ` Alex R. Mosteo
@ 2006-04-17 14:50     ` AAFellow
  2006-04-19 16:41       ` Jeffrey R. Carter
  2006-04-19 19:56       ` AAFellow
  0 siblings, 2 replies; 12+ messages in thread
From: AAFellow @ 2006-04-17 14:50 UTC (permalink / raw)


Hi Guys,

thanks for all of the help/suggestions so far....I have some new info
to report....

I had been getting the afforementioned socket exception while running
GNAT GPS in Debug mode, and setting it to break on exception.  I just
tried running the actually code normally, and it runs, with no
exceptions.  Any ideas how this could happen?  thanks!




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: (Linux) GNAT socket exception - when setting No_Delay
  2006-04-17 14:50     ` AAFellow
@ 2006-04-19 16:41       ` Jeffrey R. Carter
  2006-04-19 19:56       ` AAFellow
  1 sibling, 0 replies; 12+ messages in thread
From: Jeffrey R. Carter @ 2006-04-19 16:41 UTC (permalink / raw)


AAFellow@hotmail.com wrote:
> 
> I had been getting the afforementioned socket exception while running
> GNAT GPS in Debug mode, and setting it to break on exception.  I just
> tried running the actually code normally, and it runs, with no
> exceptions.  Any ideas how this could happen?  thanks!

Probably the GNAT socket library is raising and handling the exception.

-- 
Jeff Carter
"You couldn't catch clap in a brothel, silly English K...niggets."
Monty Python & the Holy Grail
19



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: (Linux) GNAT socket exception - when setting No_Delay
  2006-04-17 14:50     ` AAFellow
  2006-04-19 16:41       ` Jeffrey R. Carter
@ 2006-04-19 19:56       ` AAFellow
  2006-04-19 20:15         ` Alex R. Mosteo
  2006-04-20  2:41         ` Gene
  1 sibling, 2 replies; 12+ messages in thread
From: AAFellow @ 2006-04-19 19:56 UTC (permalink / raw)


Hey everyone,

I'm actually still getting the GNAT socket exception when setting the
No_Delay option when I run the code.  (Ignore my previous reply - I
didn't realize that I still had the No_Delay code commented out.)

Is there a known issue with setting the No_Delay via GNAT.sockets when
running on Linux?

thanks!




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: (Linux) GNAT socket exception - when setting No_Delay
  2006-04-19 19:56       ` AAFellow
@ 2006-04-19 20:15         ` Alex R. Mosteo
  2006-04-19 23:00           ` Jeffrey Creem
  2006-04-20  2:41         ` Gene
  1 sibling, 1 reply; 12+ messages in thread
From: Alex R. Mosteo @ 2006-04-19 20:15 UTC (permalink / raw)


AAFellow@hotmail.com wrote:
> Hey everyone,
> 
> I'm actually still getting the GNAT socket exception when setting the
> No_Delay option when I run the code.  (Ignore my previous reply - I
> didn't realize that I still had the No_Delay code commented out.)
> 
> Is there a known issue with setting the No_Delay via GNAT.sockets when
> running on Linux?

I'm confused, is this No_Delay the flag used for non blocking IO?

I used to do that with this code without issues:

procedure Set_Blocking_Io (This: in Object; Enabled : Boolean := True)
    use Gnat;
is
    Request : Sockets.Request_Type (Sockets.Non_Blocking_Io);
begin
    Request.Enabled:= not Enabled;
    Sockets.Control_Socket(This.Socket, Request);
end Set_Blocking_Io;

where This of type Object was my higher level socket abstraction.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: (Linux) GNAT socket exception - when setting No_Delay
  2006-04-19 20:15         ` Alex R. Mosteo
@ 2006-04-19 23:00           ` Jeffrey Creem
  2006-04-20  6:44             ` Alex R. Mosteo
  0 siblings, 1 reply; 12+ messages in thread
From: Jeffrey Creem @ 2006-04-19 23:00 UTC (permalink / raw)


Alex R. Mosteo wrote:
> AAFellow@hotmail.com wrote:
> 
>> Hey everyone,
>>
>> I'm actually still getting the GNAT socket exception when setting the
>> No_Delay option when I run the code.  (Ignore my previous reply - I
>> didn't realize that I still had the No_Delay code commented out.)
>>
>> Is there a known issue with setting the No_Delay via GNAT.sockets when
>> running on Linux?
> 
> 
> I'm confused, is this No_Delay the flag used for non blocking IO?
> 
> I used to do that with this code without issues:
> 
> procedure Set_Blocking_Io (This: in Object; Enabled : Boolean := True)
>    use Gnat;
> is
>    Request : Sockets.Request_Type (Sockets.Non_Blocking_Io);
> begin
>    Request.Enabled:= not Enabled;
>    Sockets.Control_Socket(This.Socket, Request);
> end Set_Blocking_Io;
> 
> where This of type Object was my higher level socket abstraction.

No delay is not related to blocking. It disables the TCP Nagle algorithm 
(http://compnetworking.about.com/od/tcpip/l/bldef_nagle.htm).

Usually one does this when you want to send small messages via TCP with 
minimal latency.

Without it, small messages are often delayed about 200msec before being 
transmitted.


Have you tried "AdaSockets" instead of GNAT sockets?



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: (Linux) GNAT socket exception - when setting No_Delay
  2006-04-19 19:56       ` AAFellow
  2006-04-19 20:15         ` Alex R. Mosteo
@ 2006-04-20  2:41         ` Gene
  1 sibling, 0 replies; 12+ messages in thread
From: Gene @ 2006-04-20  2:41 UTC (permalink / raw)


AAFellow@hotmail.com wrote:
> I'm actually still getting the GNAT socket exception when setting the
> No_Delay option when I run the code.  (Ignore my previous reply - I
> didn't realize that I still had the No_Delay code commented out.)
>
> Is there a known issue with setting the No_Delay via GNAT.sockets when
> running on Linux?
>
> thanks!

I'm no expert, but have written enough sockets code to know the source
of Gnat.Sockets fairly well.

You didn't say what version you're running. Gnat.Sockets was refined
quite a bit over the last 2 or 3 years.  The library header should be
1.27 or later.

You didn't say what exception you're getting. Socket_Error provides
additional information (through Ada.Exceptions) on what was returned by
the TCP/IP stack.  That's probably where your answer lies.

As Dmitry says it probably can't be anything except a badly compiled
library or an errno being returned by the OS.  This would have nothing
to do with Ada.  Setting options does some straightfoward argument
setup and then calls the imported C setsockopt().  If the C call sets
errno, then GNAT.Ada immediately raises the Socket_Error exception.

So it's likely that your NIC driver or TCP stack is unable to process
the No_Delay request.  Check the message in the exception!  A wild
possibility is that on your system No_Delay can be set only by root
(like promiscuous mode) and you are not root.




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: (Linux) GNAT socket exception - when setting No_Delay
  2006-04-19 23:00           ` Jeffrey Creem
@ 2006-04-20  6:44             ` Alex R. Mosteo
  2006-04-20 19:32               ` AAFellow
  0 siblings, 1 reply; 12+ messages in thread
From: Alex R. Mosteo @ 2006-04-20  6:44 UTC (permalink / raw)


Jeffrey Creem wrote:
> Alex R. Mosteo wrote:
> 
>> AAFellow@hotmail.com wrote:
>>
>>> Hey everyone,
>>>
>>> I'm actually still getting the GNAT socket exception when setting the
>>> No_Delay option when I run the code.  (Ignore my previous reply - I
>>> didn't realize that I still had the No_Delay code commented out.)
>>>
>>> Is there a known issue with setting the No_Delay via GNAT.sockets when
>>> running on Linux?
>>
>>
>>
>> I'm confused, is this No_Delay the flag used for non blocking IO?
>>
>> I used to do that with this code without issues:
>>
>> procedure Set_Blocking_Io (This: in Object; Enabled : Boolean := True)
>>    use Gnat;
>> is
>>    Request : Sockets.Request_Type (Sockets.Non_Blocking_Io);
>> begin
>>    Request.Enabled:= not Enabled;
>>    Sockets.Control_Socket(This.Socket, Request);
>> end Set_Blocking_Io;
>>
>> where This of type Object was my higher level socket abstraction.
> 
> 
> No delay is not related to blocking. It disables the TCP Nagle algorithm 
> (http://compnetworking.about.com/od/tcpip/l/bldef_nagle.htm).

Ah ok, so I was totally out of the mark. :/

> Usually one does this when you want to send small messages via TCP with 
> minimal latency.
> 
> Without it, small messages are often delayed about 200msec before being 
> transmitted.
> 
> 
> Have you tried "AdaSockets" instead of GNAT sockets?



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: (Linux) GNAT socket exception - when setting No_Delay
  2006-04-20  6:44             ` Alex R. Mosteo
@ 2006-04-20 19:32               ` AAFellow
  0 siblings, 0 replies; 12+ messages in thread
From: AAFellow @ 2006-04-20 19:32 UTC (permalink / raw)


Thanks for all the help/suggestions everyone, I figured it out.
...had to also set the "level" parameter in the set_socket_option call.




^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2006-04-20 19:32 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-13 21:34 (Linux) GNAT socket exception - when setting No_Delay AAFellow
2006-04-14  1:20 ` Robert A Duff
2006-04-17 12:14   ` Alex R. Mosteo
2006-04-17 14:50     ` AAFellow
2006-04-19 16:41       ` Jeffrey R. Carter
2006-04-19 19:56       ` AAFellow
2006-04-19 20:15         ` Alex R. Mosteo
2006-04-19 23:00           ` Jeffrey Creem
2006-04-20  6:44             ` Alex R. Mosteo
2006-04-20 19:32               ` AAFellow
2006-04-20  2:41         ` Gene
2006-04-14  9:22 ` Dmitry A. Kazakov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox