ACE_SOCK_Stream

ACE_SOCK_Stream

Post by jtuc.. » Wed, 03 Apr 2002 13:16:25



Hello,

I'm using the ACE_Service_Handler classe with an ACE_SOCK_Stream.  When my
"Service_Handler::handle_input()" method is called I know that there is some
data available for reading from my ACE_SOCK_Stream or that the connection
has been closed by a client.  Anyway, I don't know how big to allocate my
buffer in order to read in all the data at once.

i.e.

in this situation:

int Service_Handler::handle_input()
{
  int buf_size = ?;
  char socket_data = new char[buf_size];
  ACE_Time_Value *timeout = 0;
  size_t bytes_transferred;

  int result = this->peer().recv_n(
     socket_data, buf_size, timeout, bytes_transferred);

...

Quote:}

Is there a portable way to determine buf_size?

Thanks,
Johnny

=======================================================
Johnny Tucker                    Magis Networks, Inc.

direct:  (858) 523-2383          www.magisnetworks.com  
=======================================================

 
 
 

ACE_SOCK_Stream

Post by Ossama Othma » Wed, 03 Apr 2002 13:44:05


Hi,


> int Service_Handler::handle_input()
> {
>   int buf_size = ?;
>   char socket_data = new char[buf_size];
>   ACE_Time_Value *timeout = 0;
>   size_t bytes_transferred;

>   int result = this->peer().recv_n(
>      socket_data, buf_size, timeout, bytes_transferred);

> ...
> }

> Is there a portable way to determine buf_size?

The canonical tecnique is to send a fixed size "header" that contains
the length of the payload.  You could then read the appropriate size
from the fixed length header.

-Ossama

--

Distributed Object Computing Laboratory, Univ. of California at Irvine
1024D/F7A394A8 - 84ED AA0B 1203 99E4 1068  70E6 5EB7 5E71 F7A3 94A8

 
 
 

ACE_SOCK_Stream

Post by Douglas C. Schmid » Wed, 03 Apr 2002 22:31:22


Hi Johnny,

Quote:>> I'm using the ACE_Service_Handler classe with an ACE_SOCK_Stream.  When my
>> "Service_Handler::handle_input()" method is called I know that there is some
>> data available for reading from my ACE_SOCK_Stream or that the connection
>> has been closed by a client.  Anyway, I don't know how big to allocate my
>> buffer in order to read in all the data at once.

>> i.e.

>> in this situation:

>> int Service_Handler::handle_input()
>> {
>>   int buf_size = ?;
>>   char socket_data = new char[buf_size];
>>   ACE_Time_Value *timeout = 0;
>>   size_t bytes_transferred;

>>   int result = this->peer().recv_n(
>>      socket_data, buf_size, timeout, bytes_transferred);

>> ...
>> }

>> Is there a portable way to determine buf_size?

Please see Chapter 4 (particularly pages 87-88) of C++NPv1
<www.cs.wustl.edu/~schmidt/ACE/book1/> for examples of how to handle this.

thanks,

        Doug

--
Dr. Douglas C. Schmidt, Associate Professor  TEL: (949) 824-1901
Dept of Electrical & Computer Engineering    FAX: (949) 824-2321
616E Engineering Tower                       WEB: www.ece.uci.edu/~schmidt/

 
 
 

ACE_SOCK_Stream

Post by jtuc.. » Thu, 04 Apr 2002 07:00:18


Thanks Doug!  Hopefully I can talk this company into using TAO/CORBA someday
so I can float above these details.

Johnny

> -----Original Message-----

> Sent: Tuesday, April 02, 2002 5:29 AM

> Subject: Re: [ace-users] ACE_SOCK_Stream

> Hi Johnny,

> >> I'm using the ACE_Service_Handler classe with an
> ACE_SOCK_Stream.  When my
> >> "Service_Handler::handle_input()" method is called I know
> that there is some
> >> data available for reading from my ACE_SOCK_Stream or that
> the connection
> >> has been closed by a client.  Anyway, I don't know how big
> to allocate my
> >> buffer in order to read in all the data at once.

> >> i.e.

> >> in this situation:

> >> int Service_Handler::handle_input()
> >> {
> >>   int buf_size = ?;
> >>   char socket_data = new char[buf_size];
> >>   ACE_Time_Value *timeout = 0;
> >>   size_t bytes_transferred;

> >>   int result = this->peer().recv_n(
> >>      socket_data, buf_size, timeout, bytes_transferred);

> >> ...
> >> }

> >> Is there a portable way to determine buf_size?

> Please see Chapter 4 (particularly pages 87-88) of C++NPv1
> <www.cs.wustl.edu/~schmidt/ACE/book1/> for examples of how to
> handle this.

> thanks,

>         Doug
> --
> Dr. Douglas C. Schmidt, Associate Professor  TEL: (949) 824-1901
> Dept of Electrical & Computer Engineering    FAX: (949) 824-2321
> 616E Engineering Tower                       WEB:

www.ece.uci.edu/~schmidt/

 
 
 

ACE_SOCK_Stream

Post by Douglas C. Schmid » Thu, 04 Apr 2002 07:11:30


Hi Johnny,

Quote:> Thanks Doug!  Hopefully I can talk this company into using TAO/CORBA someday
> so I can float above these details.

Amen to that...

Good luck!

        Doug

 
 
 

1. Getting errno 10058 on ACE_SOCK_Stream.send_n(), please help

I'm new to this group and to ACE in general so please forgive me if this question is too basic.

I'm building a prototype server for a project and have based it on the process-per-connection logging server illustrated in C++ Network Programming Volume 1.  It is currently running on Windows XP.  The process spawning works fine (thanks ACE) and the client code is doing great, but the server appears to be operating in half-duplex mode.  There is absolutely no problem with the server receiving data from the client, but when I do an ACE_SOCK_Stream::send_n() it fails with errno = 10058, which is a Winsock error indicating that the connection was partially shutdown.  I've done pretty thorough tracing of the code and it looks as if the socket is being opened in half-duplex, but I don't know why.  I'm not doing anything fancy with ACE, and the fundamental code I'm using is basically lifted straight out of the book.  Any help on this problem would be very much appreciated.  Thank you.

Guy L. Smith

2. Would user directory

3. Fwd: [ace-users] Getting errno 10058 on ACE_SOCK_Stream.send_n(), please help

4. Service

5. ACE_SOCK_Stream and default settings.

6. advance

7. ACE_Sock_Stream buffers max size

8. looking for MAC Plus ROM for vMAC Emu.

9. select() misbehaves when switching from ACE_SOCK_Stream to ACE_SSL_SOCK_Stream

10. ACE_File_IO and ACE_SOCK_STREAM with a common ancestor class?

11. Simultaneous read & write on ACE_SOCK_Stream from two threads