Re: Multiple connection from 1 client

2011-05-10 Thread David Schwartz

On 5/9/2011 1:45 PM, Eric S. Eberhard wrote:


 int setblock(fd, mode)
 int fd;
 int mode; /* True - blocking, False - non blocking */
 {
 int flags;
 int prevmode;

 flags = fcntl(fd, F_GETFL, 0);
 prevmode = !(flags  O_NDELAY);
 if (mode)
 flags = ~O_NDELAY; /* turn blocking on */
 else
 flags |= O_NDELAY; /* turn blocking off */
 fcntl(fd, F_SETFL, flags);

 return prevmode;
 }


This code is ancient and is in desperate need of being made to conform 
to modern standards before being used.


DS

__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


Re: Multiple connection from 1 client

2011-05-10 Thread Gayathri Sundar
Hi Eric.,

First of all i am a she :) and I took a maternity break off from
work..which is why I am jobless..but busy feeding and diapering my
little one :)..sure I can take up your offer, please email me at
suraj...@gmail.com.

harsh.,

The thing is as Eric says, you really have to rewrite ur server code
once you make the fd non blocking..a simple fcntl is enuf. Also I
would personally prefer sys poll over select on Linux..u could
research about the former. Select is boring to me.
the whole idea of non blocking is that a single call to ssl accept is
not going to finish the complete ssl handshake. If you read the rfc
you will know the multiple messages that are exchanged for a single
ssl handshake, so in-between every read and write for the ssl
handshake the non blocking fd would actually give you time to do
something else . So what you really need is a state machine, which
is noting but a array of function pointers (2d) in this case.

I would write something like this

States:  ssl accept pending, ssl accepted, ssl read blocked on write,
ssl read,  ssl write blocked on read, ssl write,  ssl renegotiate
Have a function for each state specified above which would do
ssl_accept, ssl_read, ssl_write and so on.

Thanks
--Gayathri



On Monday, May 9, 2011, Eric S. Eberhard fl...@vicsmba.com wrote:
 Harsh,

 I would take up his offer of help.  Socket control over multiple sockets is 
 tricky code and very specific to what you are trying to do.  My environment 
 is single threaded and does similar things to yours -- but as Gayathri said, 
 there are many details and exceptions and although with some online help or 
 books I am sure with enough time you could do it (took me forever the first 
 time) I suspect that this offer is as good as they get.  I am not jobless 
 (lucky me) so I can't put in the time he can.

 Gayathri -- would you be interested in pure C coding on a contract basis 
 (intermittent, not really a job, more like occasional tasks) -- the code we 
 write runs on AIX, Linux, OS/X, SCO, HP/UX, Centos, etc. so it is a little 
 tricky to make work.  If you have interest let me know your rates and real 
 email and so forth.

 Thanks, Eric


 At 08:33 PM 5/6/2011, you wrote:

 Harsh.,

 If u have any specific doubts in writing this asynchronous state
 machine email me privately at suraj...@gmail.com.
 I am pretty much jobless right now and can spend some time on this.

 Thanks
 --Gayathri


 On Friday, May 6, 2011, Harshvir Sidhu hvssi...@gmail.com wrote:
 Thanks, I will give this a try.
 // Harshvir

 On Fri, May 6, 2011 at 6:44 PM, Eric S. Eberhard fl...@vicsmba.com wrote:
 Change the sockets.  This is what I use:

 int setblock(fd, mode)
 int fd;
 int mode;                       /* True - blocking, False - non blocking */
 {
         int flags;
         int prevmode;

         flags = fcntl(fd, F_GETFL, 0);
         prevmode = !(flags  O_NDELAY);
         if (mode)
                 flags = ~O_NDELAY;             /* turn blocking on */
         else
                 flags |= O_NDELAY;              /* turn blocking off */
         fcntl(fd, F_SETFL, flags);

         return prevmode;
 }

 Since it returns the existing mode you can use as such:

 prevmode = setblock(fd,0)                       /* turn of blocking */
 /* do your thing */
 (void)setblock(fd,prevmode);                    /* restore to original 
 condition */

 At 04:15 PM 5/6/2011, you wrote:

 Thanks for the reply Gayathri.
 Do you mean to changing the sockets to non blocking, or when i create bio 
 for ssl to make that as non blocking?

 Thanks.


 On Fri, May 6, 2011 at 6:03 PM, Gayathri Sundar 
 mailto:suraj...@gmail.comsuraj...@gmail.com wrote:
 Harsh,

 Okay from what I can understand, if you make ur underlying fd non blocking 
 then it would work fine. Blocking FDs, unless and until one client is 
 finished with its processing the other client will not be able to 
 communicate with the server as the previous fd is blocked. The server is 
 waiting on the 1st client to finish. When you have 3 ports and 3 clients 
 then ofcourse it will work.

 thanks
 --Gayathri



 On Fri, May 6, 2011 at 5:50 PM, Harshvir Sidhu 
 mailto:hvssi...@gmail.comhvssi...@gmail.com wrote:
 Gayatri,
 My server code is single threaded and i am using blocking sockets, i am 
 using fd_set and select to wait for event on socket, and then performing 
 operation based on the event that acts on a socket.
 I have an array of sockets to listen. So if i start listening on 3 different 
 ports and from my client machien, i try to connect on them at different 
 ports then it works fine, but when i use 1 listen port then it dont work 
 properly. What i mean to say by work properly is that the connection is 
 established, but when i am waiting for select to return event, then it dont 
 show any activity when i send data from client, only 1 of them works, 2 dont 
 work.
 In addition to that, when i use WireShark to see packets, then it shows that 
 machine has received the 

Re: Multiple connection from 1 client

2011-05-10 Thread Harshvir Sidhu
Hi Gayathri,
My Server and Client application are Windows based. Also the application
is huge, so its not possible to rewrite at this time. Maybe later we can do
that, but as for now, we are looking into alternate method for this. If we
decide to revisit this issue then i will look into this.

   Thanks.
// Harshvir
On Mon, May 9, 2011 at 6:57 PM, Gayathri Sundar suraj...@gmail.com wrote:

 Hi Eric.,

 First of all i am a she :) and I took a maternity break off from
 work..which is why I am jobless..but busy feeding and diapering my
 little one :)..sure I can take up your offer, please email me at
 suraj...@gmail.com.

 harsh.,

 The thing is as Eric says, you really have to rewrite ur server code
 once you make the fd non blocking..a simple fcntl is enuf. Also I
 would personally prefer sys poll over select on Linux..u could
 research about the former. Select is boring to me.
 the whole idea of non blocking is that a single call to ssl accept is
 not going to finish the complete ssl handshake. If you read the rfc
 you will know the multiple messages that are exchanged for a single
 ssl handshake, so in-between every read and write for the ssl
 handshake the non blocking fd would actually give you time to do
 something else . So what you really need is a state machine, which
 is noting but a array of function pointers (2d) in this case.

 I would write something like this

 States:  ssl accept pending, ssl accepted, ssl read blocked on write,
 ssl read,  ssl write blocked on read, ssl write,  ssl renegotiate
 Have a function for each state specified above which would do
 ssl_accept, ssl_read, ssl_write and so on.

 Thanks
 --Gayathri



 On Monday, May 9, 2011, Eric S. Eberhard fl...@vicsmba.com wrote:
  Harsh,
 
  I would take up his offer of help.  Socket control over multiple sockets
 is tricky code and very specific to what you are trying to do.  My
 environment is single threaded and does similar things to yours -- but as
 Gayathri said, there are many details and exceptions and although with some
 online help or books I am sure with enough time you could do it (took me
 forever the first time) I suspect that this offer is as good as they get.  I
 am not jobless (lucky me) so I can't put in the time he can.
 
  Gayathri -- would you be interested in pure C coding on a contract basis
 (intermittent, not really a job, more like occasional tasks) -- the code we
 write runs on AIX, Linux, OS/X, SCO, HP/UX, Centos, etc. so it is a little
 tricky to make work.  If you have interest let me know your rates and real
 email and so forth.
 
  Thanks, Eric
 
 
  At 08:33 PM 5/6/2011, you wrote:
 
  Harsh.,
 
  If u have any specific doubts in writing this asynchronous state
  machine email me privately at suraj...@gmail.com.
  I am pretty much jobless right now and can spend some time on this.
 
  Thanks
  --Gayathri
 
 
  On Friday, May 6, 2011, Harshvir Sidhu hvssi...@gmail.com wrote:
  Thanks, I will give this a try.
  // Harshvir
 
  On Fri, May 6, 2011 at 6:44 PM, Eric S. Eberhard fl...@vicsmba.com
 wrote:
  Change the sockets.  This is what I use:
 
  int setblock(fd, mode)
  int fd;
  int mode;   /* True - blocking, False - non blocking
 */
  {
  int flags;
  int prevmode;
 
  flags = fcntl(fd, F_GETFL, 0);
  prevmode = !(flags  O_NDELAY);
  if (mode)
  flags = ~O_NDELAY; /* turn blocking on */
  else
  flags |= O_NDELAY;  /* turn blocking off */
  fcntl(fd, F_SETFL, flags);
 
  return prevmode;
  }
 
  Since it returns the existing mode you can use as such:
 
  prevmode = setblock(fd,0)   /* turn of blocking */
  /* do your thing */
  (void)setblock(fd,prevmode);/* restore to original
 condition */
 
  At 04:15 PM 5/6/2011, you wrote:
 
  Thanks for the reply Gayathri.
  Do you mean to changing the sockets to non blocking, or when i create
 bio for ssl to make that as non blocking?
 
  Thanks.
 
 
  On Fri, May 6, 2011 at 6:03 PM, Gayathri Sundar mailto:
 suraj...@gmail.comsuraj...@gmail.com wrote:
  Harsh,
 
  Okay from what I can understand, if you make ur underlying fd non
 blocking then it would work fine. Blocking FDs, unless and until one client
 is finished with its processing the other client will not be able to
 communicate with the server as the previous fd is blocked. The server is
 waiting on the 1st client to finish. When you have 3 ports and 3 clients
 then ofcourse it will work.
 
  thanks
  --Gayathri
 
 
 
  On Fri, May 6, 2011 at 5:50 PM, Harshvir Sidhu mailto:
 hvssi...@gmail.comhvssi...@gmail.com wrote:
  Gayatri,
  My server code is single threaded and i am using blocking sockets, i am
 using fd_set and select to wait for event on socket, and then performing
 operation based on the event that acts on a socket.
  I have an array of sockets to listen. So if i start listening on 3
 different ports and from 

Re: Multiple connection from 1 client

2011-05-09 Thread Harshvir Sidhu
 Hi,
I used the following code to change the socket to non blocking, but its
still not successful, now its not even able to complete SSL_Accept. I am
changing the socket option for the accepted socket.

 unsigned long iMode = 1;
 int nReturn = ioctlsocket(sock, FIONBIO, iMode);
 if(nReturn != NO_ERROR)
 {
 printf((ioctlsocket failed with error: %ld\n, nReturn));
 }

Also i suspect, that if i change the socket to non blocking, then my
current read write code will not work. i mean the one in which i use FD_SET
and select to perform operations.

Thanks.

// Harshvir

On Fri, May 6, 2011 at 10:33 PM, Gayathri Sundar suraj...@gmail.com wrote:

 Harsh.,

 If u have any specific doubts in writing this asynchronous state
 machine email me privately at suraj...@gmail.com.
 I am pretty much jobless right now and can spend some time on this.

 Thanks
 --Gayathri


 On Friday, May 6, 2011, Harshvir Sidhu hvssi...@gmail.com wrote:
  Thanks, I will give this a try.
  // Harshvir
 
  On Fri, May 6, 2011 at 6:44 PM, Eric S. Eberhard fl...@vicsmba.com
 wrote:
  Change the sockets.  This is what I use:
 
  int setblock(fd, mode)
  int fd;
  int mode;   /* True - blocking, False - non blocking
 */
  {
  int flags;
  int prevmode;
 
  flags = fcntl(fd, F_GETFL, 0);
  prevmode = !(flags  O_NDELAY);
  if (mode)
  flags = ~O_NDELAY; /* turn blocking on */
  else
  flags |= O_NDELAY;  /* turn blocking off */
  fcntl(fd, F_SETFL, flags);
 
  return prevmode;
  }
 
  Since it returns the existing mode you can use as such:
 
  prevmode = setblock(fd,0)   /* turn of blocking */
  /* do your thing */
  (void)setblock(fd,prevmode);/* restore to original
 condition */
 
  At 04:15 PM 5/6/2011, you wrote:
 
  Thanks for the reply Gayathri.
  Do you mean to changing the sockets to non blocking, or when i create bio
 for ssl to make that as non blocking?
 
  Thanks.
 
 
  On Fri, May 6, 2011 at 6:03 PM, Gayathri Sundar mailto:
 suraj...@gmail.comsuraj...@gmail.com wrote:
  Harsh,
 
  Okay from what I can understand, if you make ur underlying fd non
 blocking then it would work fine. Blocking FDs, unless and until one client
 is finished with its processing the other client will not be able to
 communicate with the server as the previous fd is blocked. The server is
 waiting on the 1st client to finish. When you have 3 ports and 3 clients
 then ofcourse it will work.
 
  thanks
  --Gayathri
 
 
 
  On Fri, May 6, 2011 at 5:50 PM, Harshvir Sidhu mailto:
 hvssi...@gmail.comhvssi...@gmail.com wrote:
  Gayatri,
  My server code is single threaded and i am using blocking sockets, i am
 using fd_set and select to wait for event on socket, and then performing
 operation based on the event that acts on a socket.
  I have an array of sockets to listen. So if i start listening on 3
 different ports and from my client machien, i try to connect on them at
 different ports then it works fine, but when i use 1 listen port then it
 dont work properly. What i mean to say by work properly is that the
 connection is established, but when i am waiting for select to return event,
 then it dont show any activity when i send data from client, only 1 of them
 works, 2 dont work.
  In addition to that, when i use WireShark to see packets, then it shows
 that machine has received the packet from client. But server dont show that
 alert.
  Thats why i think it could be some socket option which is affecting it.
 
  // Harshvir
 
 
 
  On Fri, May 6, 2011 at 5:37 PM, Gayathri Sundar mailto:
 suraj...@gmail.comsuraj...@gmail.com wrote:
  Harshvir,
 
  SO_REUSEADDR sock option has noting to do with ur problem, please go thro
 the socket ops man page to get a better understanding. First find out if ur
 server code is a blocking i/o or non blocking I/O..if former then
 connections will be handled sequentially..only after the 1st client is
 finished will the server be able to respond to the 2nd connect request. If
 non blocking then there should be no problem. Check the code if you see and
 O_NONBLOCK flag set in some fcntl call or check for FIONBIO flag.
 
  Thanks
  --Gayathri
 
 
 
  On Fri, May 6, 2011 at 5:29 PM, Harshvir Sidhu mailto:
 hvssi...@gmail.comhvssi...@gmail.com wrote:
  Well i think this link is for my question.
  I have already done 1-5 from the Before you ask list.
  Number 6, i dont know anyone who use openssl.
  Number 7, it will take a lot of time to go through all the code, i was
 just trying to save some time. I thought user discussion forums are for this
 only. I apologize for my understanding.
 
  __
 OpenSSL Project http://www.openssl.org
 User Support Mailing Listopenssl-users@openssl.org
 

Re: Multiple connection from 1 client

2011-05-09 Thread Gayathri Sundar
Hi.,

Yes, once you make the socket noblocking, your current ssl API,s will
not work. that is why I asked you to write the asynchronous state
machine. Go thro the man pages for ssl accept, ssl read, ssl write for
non blocking cases. You need to handle special cases called want read
and write errors.

I will send a detailed email a little later.

Thanks
--Gayathri
On Monday, May 9, 2011, Harshvir Sidhu hvssi...@gmail.com wrote:

 Hi,
     I used the following code to change the socket to non blocking, but its 
 still not successful, now its not even able to complete SSL_Accept. I am 
 changing the socket option for the accepted socket.

  unsigned long iMode = 1;
  int nReturn = ioctlsocket(sock, FIONBIO, iMode);
  if(nReturn != NO_ERROR)
  {
  printf((ioctlsocket failed with error: %ld\n, nReturn));
  }

     Also i suspect, that if i change the socket to non blocking, then my 
 current read write code will not work. i mean the one in which i use FD_SET 
 and select to perform operations.

 Thanks.

 // Harshvir




 On Fri, May 6, 2011 at 10:33 PM, Gayathri Sundar suraj...@gmail.com wrote:
 Harsh.,

 If u have any specific doubts in writing this asynchronous state
 machine email me privately at suraj...@gmail.com.
 I am pretty much jobless right now and can spend some time on this.

 Thanks
 --Gayathri





 On Friday, May 6, 2011, Harshvir Sidhu hvssi...@gmail.com wrote:
 Thanks, I will give this a try.
 // Harshvir

 On Fri, May 6, 2011 at 6:44 PM, Eric S. Eberhard fl...@vicsmba.com wrote:
 Change the sockets.  This is what I use:

 int setblock(fd, mode)
 int fd;
 int mode;                       /* True - blocking, False - non blocking */
 {
         int flags;
         int prevmode;

         flags = fcntl(fd, F_GETFL, 0);
         prevmode = !(flags  O_NDELAY);
         if (mode)
                 flags = ~O_NDELAY;             /* turn blocking on */
         else
                 flags |= O_NDELAY;              /* turn blocking off */
         fcntl(fd, F_SETFL, flags);

         return prevmode;
 }

 Since it returns the existing mode you can use as such:

 prevmode = setblock(fd,0)                       /* turn of blocking */
 /* do your thing */
 (void)setblock(fd,prevmode);                    /* restore to original 
 condition */

 At 04:15 PM 5/6/2011, you wrote:

 Thanks for the reply Gayathri.
 Do you mean to changing the sockets to non blocking, or when i create bio 
 for ssl to make that as non blocking?

 Thanks.


 On Fri, May 6, 2011 at 6:03 PM, Gayathri Sundar 
 mailto:suraj...@gmail.comsuraj...@gmail.com wrote:
 Harsh,

 Okay from what I can understand, if you make ur underlying fd non blocking 
 then it would work fine. Blocking FDs, unless and until one client is 
 finished with its processing the other client will not be able to 
 communicate with the server as the previous fd is blocked. The server is 
 waiting on the 1st client to finish. When you have 3 ports and 3 clients 
 then ofcourse it will work.

 thanks
 --Gayathri



 On Fri, May 6, 2011 at 5:50 PM, Harshvir Sidhu 
 mailto:hvssi...@gmail.comhvssi...@gmail.com wrote:
 Gayatri,
 My server code is single threaded and i am using blocking sockets, i am 
 using fd_set and select to wait for event on socket, and then performing 
 operation based on the event that acts on a socket.
 I have an array of sockets to listen. So if i start listening on 3 different 
 ports and from my client machien, i try to connect on them at different 
 ports then it works fine, but when i use 1 listen port then it dont work 
 properly. What i mean to say by work properly is that the connection is 
 established, but when i am waiting for select to return event, then it dont 
 show any activity when i send data from client, only 1 of them works, 2 dont 
 work.
 In addition to that, when i use WireShark to see packets, then it shows that 
 machine has received the packet from client. But server dont show that alert.
 Thats why i think it could be some socket option which is affecting it.

 // Harshvir



 On Fri, May 6, 2011 at 5:37 PM, Gayathri Sundar 
 mailto:suraj...@gmail.comsuraj...@gmail.com wrote:
 Harshvir,

 SO_REUSEADDR sock option has noting to do with ur problem, please go thro 
 the socket ops man page to get a better understanding. First find out if ur 
 server code is a blocking i/o or non blocking I/O..if former then 
 connections will be handled sequentially..only after the 1st client is 
 finished will the server be able to respond to the 2nd connect request. If 
 non blocking then there should be no problem. Check the code if you see and 
 O_NONBLOCK flag set in some fcntl call or check for FIONBIO flag.

 Thanks
 --Gayathri



 On Fri, May 6, 2011 at 5:29 PM, Harshvir Sidhu 
 mailto:hvssi...@gmail.comhvssi...@gmail.com wrote:
 Well i think this link is for my question.
 I have already done 1-5 from the Before you ask list.
 Number 6, i dont know anyone who use openssl.
 Number 7, 

Re: Multiple connection from 1 client

2011-05-09 Thread David Schwartz

On 5/9/2011 6:27 AM, Harshvir Sidhu wrote:


 Also i suspect, that if i change the socket to non blocking, then
my current read write code will not work. i mean the one in which i use
FD_SET and select to perform operations.
Thanks.


It's very easy to get things wrong and it won't work unless you get 
everything right.


The most common mistake is refusing to call one of the SSL_* functions 
until you get a 'select' hit. You should only do that if OpenSSL 
specifically tells you to do that.


The second most common mistake is assuming that an SSL connection has 
separate read and write readiness, like a TCP connection does. An SSL 
connection is a single state machine and so has only a single state. (So 
if SSL_Read returns WANT_READ and then you call SSL_Write, regardless of 
what return value you get, the WANT_READ from SSL_Read is invalidated 
because SSL_Write can change the state of the SSL connection.)


DS

__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


Re: Multiple connection from 1 client

2011-05-09 Thread Eric S. Eberhard

Harsh,

I would take up his offer of help.  Socket control over multiple 
sockets is tricky code and very specific to what you are trying to 
do.  My environment is single threaded and does similar things to 
yours -- but as Gayathri said, there are many details and exceptions 
and although with some online help or books I am sure with enough 
time you could do it (took me forever the first time) I suspect that 
this offer is as good as they get.  I am not jobless (lucky me) so I 
can't put in the time he can.


Gayathri -- would you be interested in pure C coding on a contract 
basis (intermittent, not really a job, more like occasional tasks) -- 
the code we write runs on AIX, Linux, OS/X, SCO, HP/UX, Centos, etc. 
so it is a little tricky to make work.  If you have interest let me 
know your rates and real email and so forth.


Thanks, Eric


At 08:33 PM 5/6/2011, you wrote:

Harsh.,

If u have any specific doubts in writing this asynchronous state
machine email me privately at suraj...@gmail.com.
I am pretty much jobless right now and can spend some time on this.

Thanks
--Gayathri


On Friday, May 6, 2011, Harshvir Sidhu hvssi...@gmail.com wrote:
 Thanks, I will give this a try.
 // Harshvir

 On Fri, May 6, 2011 at 6:44 PM, Eric S. Eberhard fl...@vicsmba.com wrote:
 Change the sockets.  This is what I use:

 int setblock(fd, mode)
 int fd;
 int mode;   /* True - blocking, False - non blocking */
 {
 int flags;
 int prevmode;

 flags = fcntl(fd, F_GETFL, 0);
 prevmode = !(flags  O_NDELAY);
 if (mode)
 flags = ~O_NDELAY; /* turn blocking on */
 else
 flags |= O_NDELAY;  /* turn blocking off */
 fcntl(fd, F_SETFL, flags);

 return prevmode;
 }

 Since it returns the existing mode you can use as such:

 prevmode = setblock(fd,0)   /* turn of blocking */
 /* do your thing */
 (void)setblock(fd,prevmode);/* restore to 
original condition */


 At 04:15 PM 5/6/2011, you wrote:

 Thanks for the reply Gayathri.
 Do you mean to changing the sockets to non blocking, or when i 
create bio for ssl to make that as non blocking?


 Thanks.


 On Fri, May 6, 2011 at 6:03 PM, Gayathri Sundar 
mailto:suraj...@gmail.comsuraj...@gmail.com wrote:

 Harsh,

 Okay from what I can understand, if you make ur underlying fd non 
blocking then it would work fine. Blocking FDs, unless and until 
one client is finished with its processing the other client will 
not be able to communicate with the server as the previous fd is 
blocked. The server is waiting on the 1st client to finish. When 
you have 3 ports and 3 clients then ofcourse it will work.


 thanks
 --Gayathri



 On Fri, May 6, 2011 at 5:50 PM, Harshvir Sidhu 
mailto:hvssi...@gmail.comhvssi...@gmail.com wrote:

 Gayatri,
 My server code is single threaded and i am using blocking 
sockets, i am using fd_set and select to wait for event on socket, 
and then performing operation based on the event that acts on a socket.
 I have an array of sockets to listen. So if i start listening on 
3 different ports and from my client machien, i try to connect on 
them at different ports then it works fine, but when i use 1 listen 
port then it dont work properly. What i mean to say by work 
properly is that the connection is established, but when i am 
waiting for select to return event, then it dont show any activity 
when i send data from client, only 1 of them works, 2 dont work.
 In addition to that, when i use WireShark to see packets, then it 
shows that machine has received the packet from client. But server 
dont show that alert.

 Thats why i think it could be some socket option which is affecting it.

 // Harshvir



 On Fri, May 6, 2011 at 5:37 PM, Gayathri Sundar 
mailto:suraj...@gmail.comsuraj...@gmail.com wrote:

 Harshvir,

 SO_REUSEADDR sock option has noting to do with ur problem, please 
go thro the socket ops man page to get a better understanding. 
First find out if ur server code is a blocking i/o or non blocking 
I/O..if former then connections will be handled sequentially..only 
after the 1st client is finished will the server be able to respond 
to the 2nd connect request. If non blocking then there should be no 
problem. Check the code if you see and O_NONBLOCK flag set in some 
fcntl call or check for FIONBIO flag.


 Thanks
 --Gayathri



 On Fri, May 6, 2011 at 5:29 PM, Harshvir Sidhu 
mailto:hvssi...@gmail.comhvssi...@gmail.com wrote:

 Well i think this link is for my question.
 I have already done 1-5 from the Before you ask list.
 Number 6, i dont know anyone who use openssl.
 Number 7, it will take a lot of time to go through all the code, 
i was just trying to save some time. I thought user discussion 
forums are for this only. I apologize for my understanding.


__
OpenSSL Project 

Multiple connection from 1 client

2011-05-06 Thread Harshvir Sidhu
Hi,

   I have a server application, which accepts normal sockets and ssl socket
connections. I am trying to make 3 connections to server from 1 client
machine, on same server port.
   When i connect on normal sockets then it works with any number of
connections.
   When i tried to connect SSL then they dont work. If i connect 1 client
then it works.

   In my listen socket, I have SO_REUSEADDR socket option, at first i
thought might be this is causing issue, but i tried to use
SO_EXCLUSIVEADDRUSE even then it dont work.

   Has someone seen some issue like this, any possible suggestion for this?

Thanks,

// Harshvir


Re: Multiple connection from 1 client

2011-05-06 Thread derleader mail
 Hi,  
  

 I have a server application, which accepts normal sockets and ssl socket 
connections.
I am trying to make 3 connections to server from 1 client machine, on same 
server port.  

 When i connect on normal sockets then it works with any number of connections. 
 

 When i tried to connect SSL then they dont work. If i connect 1 client then it 
works.  
  


In my listen socket, I have SO_REUSEADDR socket
option, at first i thought might be this is causing issue, but i tried to use 
SO_EXCLUSIVEADDRUSE even then it dont work.  
  

 Has someone seen some issue like this, any possible suggestion for this?  
  Thanks,  
  // Harshvir  

Hi,

 
Can you show us the source code. Paste it into pastebin.org.

Regards
 

Re: Multiple connection from 1 client

2011-05-06 Thread Harshvir Sidhu
My code is all jumbled up, its a big big code. I dont think i can share the
code.
If there is some particular call that you want to see, please let me know i
will share the function call or block of calls.

Thanks.

On Fri, May 6, 2011 at 2:22 PM, derleader mail derlea...@abv.bg wrote:

   Hi,

I have a server application, which accepts normal sockets and ssl socket
 connections. I am trying to make 3 connections to server from 1 client
 machine, on same server port.
When i connect on normal sockets then it works with any number of
 connections.
When i tried to connect SSL then they dont work. If i connect 1 client
 then it works.

In my listen socket, I have SO_REUSEADDR socket option, at first i
 thought might be this is causing issue, but i tried to use
 SO_EXCLUSIVEADDRUSE even then it dont work.

Has someone seen some issue like this, any possible suggestion for this?

 Thanks,

 // Harshvir

 Hi,

  Can you show us the source code. Paste it into pastebin.org.

 Regards



Re: Multiple connection from 1 client

2011-05-06 Thread Michael S. Zick
On Fri May 6 2011, derleader mail wrote:
  Hi,  
   
 
  I have a server application, which accepts normal sockets and ssl socket 
 connections.
 I am trying to make 3 connections to server from 1 client machine, on same 
 server port.  
 
  When i connect on normal sockets then it works with any number of 
 connections.  
 
  When i tried to connect SSL then they dont work. If i connect 1 client then 
 it works.  
   
 
 
 In my listen socket, I have SO_REUSEADDR socket
 option, at first i thought might be this is causing issue, but i tried to use 
 SO_EXCLUSIVEADDRUSE even then it dont work.  
   
 
  Has someone seen some issue like this, any possible suggestion for this?  
   Thanks,  
   // Harshvir  
 
 Hi,
 
  
 Can you show us the source code. Paste it into pastebin.org.
 

Is there some reason you ask every poster on this mailing list
for their source code?

Mike
 Regards
  


__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


RE: Multiple connection from 1 client

2011-05-06 Thread Jeremy Farrell


From: Harshvir Sidhu

Hi,

   I have a server application, which accepts normal sockets and ssl socket 
connections. I am trying to make 3 connections to server from 1 client machine, 
on same server port.
   When i connect on normal sockets then it works with any number of 
connections.
   When i tried to connect SSL then they dont work. If i connect 1 client then 
it works.

   In my listen socket, I have SO_REUSEADDR socket option, at first i thought 
might be this is causing issue, but i tried to use SO_EXCLUSIVEADDRUSE even 
then it dont work.

   Has someone seen some issue like this, any possible suggestion for this?

Thanks,

// Harshvir

http://www.catb.org/~esr/faqs/smart-questions.html




Re: Multiple connection from 1 client

2011-05-06 Thread Harshvir Sidhu
Well i think this link is for my question.
I have already done 1-5 from the Before you ask list.
Number 6, i dont know anyone who use openssl.
Number 7, it will take a lot of time to go through all the code, i was just
trying to save some time. I thought user discussion forums are for this
only. I apologize for my understanding.


On Fri, May 6, 2011 at 5:18 PM, Jeremy Farrell jfarr...@pillardata.comwrote:



  *From:* Harshvir Sidhu

  Hi,

I have a server application, which accepts normal sockets and ssl socket
 connections. I am trying to make 3 connections to server from 1 client
 machine, on same server port.
When i connect on normal sockets then it works with any number of
 connections.
When i tried to connect SSL then they dont work. If i connect 1 client
 then it works.

In my listen socket, I have SO_REUSEADDR socket option, at first i
 thought might be this is causing issue, but i tried to use
 SO_EXCLUSIVEADDRUSE even then it dont work.

Has someone seen some issue like this, any possible suggestion for this?

 Thanks,

 // Harshvir


 http://www.catb.org/~esr/faqs/smart-questions.html





Re: Multiple connection from 1 client

2011-05-06 Thread Gayathri Sundar
Harshvir,

SO_REUSEADDR sock option has noting to do with ur problem, please go thro
the socket ops man page to get a better understanding. First find out if ur
server code is a blocking i/o or non blocking I/O..if former then
connections will be handled sequentially..only after the 1st client is
finished will the server be able to respond to the 2nd connect request. If
non blocking then there should be no problem. Check the code if you see and
O_NONBLOCK flag set in some fcntl call or check for FIONBIO flag.

Thanks
--Gayathri

On Fri, May 6, 2011 at 5:29 PM, Harshvir Sidhu hvssi...@gmail.com wrote:

 Well i think this link is for my question.
 I have already done 1-5 from the Before you ask list.
 Number 6, i dont know anyone who use openssl.
 Number 7, it will take a lot of time to go through all the code, i was just
 trying to save some time. I thought user discussion forums are for this
 only. I apologize for my understanding.


 On Fri, May 6, 2011 at 5:18 PM, Jeremy Farrell jfarr...@pillardata.comwrote:



  *From:* Harshvir Sidhu

  Hi,

I have a server application, which accepts normal sockets and ssl
 socket connections. I am trying to make 3 connections to server from 1
 client machine, on same server port.
When i connect on normal sockets then it works with any number of
 connections.
When i tried to connect SSL then they dont work. If i connect 1 client
 then it works.

In my listen socket, I have SO_REUSEADDR socket option, at first i
 thought might be this is causing issue, but i tried to use
 SO_EXCLUSIVEADDRUSE even then it dont work.

Has someone seen some issue like this, any possible suggestion for
 this?

 Thanks,

 // Harshvir


 http://www.catb.org/~esr/faqs/smart-questions.html







Re: Multiple connection from 1 client

2011-05-06 Thread Harshvir Sidhu
Gayatri,
My server code is single threaded and i am using blocking sockets, i am
using fd_set and select to wait for event on socket, and then performing
operation based on the event that acts on a socket.
I have an array of sockets to listen. So if i start listening on 3 different
ports and from my client machien, i try to connect on them at different
ports then it works fine, but when i use 1 listen port then it dont work
properly. What i mean to say by work properly is that the connection is
established, but when i am waiting for select to return event, then it dont
show any activity when i send data from client, only 1 of them works, 2 dont
work.
In addition to that, when i use WireShark to see packets, then it shows that
machine has received the packet from client. But server dont show that
alert.
Thats why i think it could be some socket option which is affecting it.

// Harshvir


On Fri, May 6, 2011 at 5:37 PM, Gayathri Sundar suraj...@gmail.com wrote:

 Harshvir,

 SO_REUSEADDR sock option has noting to do with ur problem, please go thro
 the socket ops man page to get a better understanding. First find out if ur
 server code is a blocking i/o or non blocking I/O..if former then
 connections will be handled sequentially..only after the 1st client is
 finished will the server be able to respond to the 2nd connect request. If
 non blocking then there should be no problem. Check the code if you see and
 O_NONBLOCK flag set in some fcntl call or check for FIONBIO flag.

 Thanks
 --Gayathri


 On Fri, May 6, 2011 at 5:29 PM, Harshvir Sidhu hvssi...@gmail.com wrote:

 Well i think this link is for my question.
 I have already done 1-5 from the Before you ask list.
 Number 6, i dont know anyone who use openssl.
 Number 7, it will take a lot of time to go through all the code, i was
 just trying to save some time. I thought user discussion forums are for this
 only. I apologize for my understanding.


 On Fri, May 6, 2011 at 5:18 PM, Jeremy Farrell 
 jfarr...@pillardata.comwrote:



  *From:* Harshvir Sidhu

  Hi,

I have a server application, which accepts normal sockets and ssl
 socket connections. I am trying to make 3 connections to server from 1
 client machine, on same server port.
When i connect on normal sockets then it works with any number of
 connections.
When i tried to connect SSL then they dont work. If i connect 1 client
 then it works.

In my listen socket, I have SO_REUSEADDR socket option, at first i
 thought might be this is causing issue, but i tried to use
 SO_EXCLUSIVEADDRUSE even then it dont work.

Has someone seen some issue like this, any possible suggestion for
 this?

 Thanks,

 // Harshvir


 http://www.catb.org/~esr/faqs/smart-questions.html








Re: Multiple connection from 1 client

2011-05-06 Thread Gayathri Sundar
Harsh,

Okay from what I can understand, if you make ur underlying fd non blocking
then it would work fine. Blocking FDs, unless and until one client is
finished with its processing the other client will not be able to
communicate with the server as the previous fd is blocked. The server is
waiting on the 1st client to finish. When you have 3 ports and 3 clients
then ofcourse it will work.

thanks
--Gayathri

On Fri, May 6, 2011 at 5:50 PM, Harshvir Sidhu hvssi...@gmail.com wrote:

 Gayatri,
 My server code is single threaded and i am using blocking sockets, i am
 using fd_set and select to wait for event on socket, and then performing
 operation based on the event that acts on a socket.
 I have an array of sockets to listen. So if i start listening on 3
 different ports and from my client machien, i try to connect on them at
 different ports then it works fine, but when i use 1 listen port then it
 dont work properly. What i mean to say by work properly is that the
 connection is established, but when i am waiting for select to return event,
 then it dont show any activity when i send data from client, only 1 of them
 works, 2 dont work.
 In addition to that, when i use WireShark to see packets, then it shows
 that machine has received the packet from client. But server dont show that
 alert.
 Thats why i think it could be some socket option which is affecting it.

 // Harshvir


 On Fri, May 6, 2011 at 5:37 PM, Gayathri Sundar suraj...@gmail.comwrote:

 Harshvir,

 SO_REUSEADDR sock option has noting to do with ur problem, please go thro
 the socket ops man page to get a better understanding. First find out if ur
 server code is a blocking i/o or non blocking I/O..if former then
 connections will be handled sequentially..only after the 1st client is
 finished will the server be able to respond to the 2nd connect request. If
 non blocking then there should be no problem. Check the code if you see and
 O_NONBLOCK flag set in some fcntl call or check for FIONBIO flag.

 Thanks
 --Gayathri


 On Fri, May 6, 2011 at 5:29 PM, Harshvir Sidhu hvssi...@gmail.comwrote:

 Well i think this link is for my question.
 I have already done 1-5 from the Before you ask list.
 Number 6, i dont know anyone who use openssl.
 Number 7, it will take a lot of time to go through all the code, i was
 just trying to save some time. I thought user discussion forums are for this
 only. I apologize for my understanding.


 On Fri, May 6, 2011 at 5:18 PM, Jeremy Farrell 
 jfarr...@pillardata.comwrote:



  *From:* Harshvir Sidhu

  Hi,

I have a server application, which accepts normal sockets and ssl
 socket connections. I am trying to make 3 connections to server from 1
 client machine, on same server port.
When i connect on normal sockets then it works with any number of
 connections.
When i tried to connect SSL then they dont work. If i connect 1
 client then it works.

In my listen socket, I have SO_REUSEADDR socket option, at first i
 thought might be this is causing issue, but i tried to use
 SO_EXCLUSIVEADDRUSE even then it dont work.

Has someone seen some issue like this, any possible suggestion for
 this?

 Thanks,

 // Harshvir


 http://www.catb.org/~esr/faqs/smart-questions.html









Re: Multiple connection from 1 client

2011-05-06 Thread Eric S. Eberhard
And I cannot imagine a case where a blocking FD is useful except it 
is lazier to code that way.  You need to use non-blocking. E


At 04:03 PM 5/6/2011, you wrote:

Harsh,

Okay from what I can understand, if you make ur underlying fd non 
blocking then it would work fine. Blocking FDs, unless and until one 
client is finished with its processing the other client will not be 
able to communicate with the server as the previous fd is blocked. 
The server is waiting on the 1st client to finish. When you have 3 
ports and 3 clients then ofcourse it will work.


thanks
--Gayathri

On Fri, May 6, 2011 at 5:50 PM, Harshvir Sidhu 
mailto:hvssi...@gmail.comhvssi...@gmail.com wrote:

Gayatri,
My server code is single threaded and i am using blocking sockets, i 
am using fd_set and select to wait for event on socket, and then 
performing operation based on the event that acts on a socket.
I have an array of sockets to listen. So if i start listening on 3 
different ports and from my client machien, i try to connect on them 
at different ports then it works fine, but when i use 1 listen port 
then it dont work properly. What i mean to say by work properly is 
that the connection is established, but when i am waiting for select 
to return event, then it dont show any activity when i send data 
from client, only 1 of them works, 2 dont work.
In addition to that, when i use WireShark to see packets, then it 
shows that machine has received the packet from client. But server 
dont show that alert.

Thats why i think it could be some socket option which is affecting it.

// Harshvir


On Fri, May 6, 2011 at 5:37 PM, Gayathri Sundar 
mailto:suraj...@gmail.comsuraj...@gmail.com wrote:

Harshvir,

SO_REUSEADDR sock option has noting to do with ur problem, please go 
thro the socket ops man page to get a better understanding. First 
find out if ur server code is a blocking i/o or non blocking I/O..if 
former then connections will be handled sequentially..only after the 
1st client is finished will the server be able to respond to the 2nd 
connect request. If non blocking then there should be no problem. 
Check the code if you see and O_NONBLOCK flag set in some fcntl call 
or check for FIONBIO flag.


Thanks
--Gayathri


On Fri, May 6, 2011 at 5:29 PM, Harshvir Sidhu 
mailto:hvssi...@gmail.comhvssi...@gmail.com wrote:

Well i think this link is for my question.
I have already done 1-5 from the Before you ask list.
Number 6, i dont know anyone who use openssl.
Number 7, it will take a lot of time to go through all the code, i 
was just trying to save some time. I thought user discussion forums 
are for this only. I apologize for my understanding.



On Fri, May 6, 2011 at 5:18 PM, Jeremy Farrell 
mailto:jfarr...@pillardata.comjfarr...@pillardata.com wrote:



From: Harshvir Sidhu

Hi,

   I have a server application, which accepts normal sockets and 
ssl socket connections. I am trying to make 3 connections to server 
from 1 client machine, on same server port.
   When i connect on normal sockets then it works with any number 
of connections.
   When i tried to connect SSL then they dont work. If i connect 1 
client then it works.


   In my listen socket, I have SO_REUSEADDR socket option, at first 
i thought might be this is causing issue, but i tried to use 
SO_EXCLUSIVEADDRUSE even then it dont work.


   Has someone seen some issue like this, any possible suggestion for this?

Thanks,

// Harshvir


http://www.catb.org/~esr/faqs/smart-questions.htmlhttp://www.catb.org/~esr/faqs/smart-questions.html









Eric S. Eberhard
(928) 567-3727  Voice
(928) 567-6122  Fax
(928) 301-7537   Cell

Vertical Integrated Computer Systems, LLC
Metropolis Support, LLC

For Metropolis support and VICS MBA Supporthttp://www.vicsmba.com

Pictures of Snake in Spring

http://www.facebook.com/album.php?aid=115547id=1409661701l=1c375e1f49

Pictures of Camp Verde

http://www.facebook.com/album.php?aid=12771id=1409661701l=fc0e0a2bcf

Pictures of Land Cruiser in Sedona

http://www.facebook.com/album.php?aid=50953id=1409661701

Pictures of Flagstaff area near our cabin

http://www.facebook.com/album.php?aid=12750id=1409661701

Pictures of Cheryl in a Horse Show

http://www.facebook.com/album.php?aid=32484id=1409661701


Pictures of the AZ Desert

http://www.facebook.com/album.php?aid=58827id=1409661701

(You can see why we love this state :-) )








__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


Re: Multiple connection from 1 client

2011-05-06 Thread Harshvir Sidhu
Thanks for the reply Gayathri.
Do you mean to changing the sockets to non blocking, or when i create bio
for ssl to make that as non blocking?

Thanks.

On Fri, May 6, 2011 at 6:03 PM, Gayathri Sundar suraj...@gmail.com wrote:

 Harsh,

 Okay from what I can understand, if you make ur underlying fd non blocking
 then it would work fine. Blocking FDs, unless and until one client is
 finished with its processing the other client will not be able to
 communicate with the server as the previous fd is blocked. The server is
 waiting on the 1st client to finish. When you have 3 ports and 3 clients
 then ofcourse it will work.

 thanks
 --Gayathri


 On Fri, May 6, 2011 at 5:50 PM, Harshvir Sidhu hvssi...@gmail.com wrote:

 Gayatri,
 My server code is single threaded and i am using blocking sockets, i am
 using fd_set and select to wait for event on socket, and then performing
 operation based on the event that acts on a socket.
 I have an array of sockets to listen. So if i start listening on 3
 different ports and from my client machien, i try to connect on them at
 different ports then it works fine, but when i use 1 listen port then it
 dont work properly. What i mean to say by work properly is that the
 connection is established, but when i am waiting for select to return event,
 then it dont show any activity when i send data from client, only 1 of them
 works, 2 dont work.
 In addition to that, when i use WireShark to see packets, then it shows
 that machine has received the packet from client. But server dont show that
 alert.
 Thats why i think it could be some socket option which is affecting it.

 // Harshvir


 On Fri, May 6, 2011 at 5:37 PM, Gayathri Sundar suraj...@gmail.comwrote:

 Harshvir,

 SO_REUSEADDR sock option has noting to do with ur problem, please go thro
 the socket ops man page to get a better understanding. First find out if ur
 server code is a blocking i/o or non blocking I/O..if former then
 connections will be handled sequentially..only after the 1st client is
 finished will the server be able to respond to the 2nd connect request. If
 non blocking then there should be no problem. Check the code if you see and
 O_NONBLOCK flag set in some fcntl call or check for FIONBIO flag.

 Thanks
 --Gayathri


 On Fri, May 6, 2011 at 5:29 PM, Harshvir Sidhu hvssi...@gmail.comwrote:

 Well i think this link is for my question.
 I have already done 1-5 from the Before you ask list.
 Number 6, i dont know anyone who use openssl.
 Number 7, it will take a lot of time to go through all the code, i was
 just trying to save some time. I thought user discussion forums are for 
 this
 only. I apologize for my understanding.


 On Fri, May 6, 2011 at 5:18 PM, Jeremy Farrell jfarr...@pillardata.com
  wrote:



  *From:* Harshvir Sidhu

  Hi,

I have a server application, which accepts normal sockets and ssl
 socket connections. I am trying to make 3 connections to server from 1
 client machine, on same server port.
When i connect on normal sockets then it works with any number of
 connections.
When i tried to connect SSL then they dont work. If i connect 1
 client then it works.

In my listen socket, I have SO_REUSEADDR socket option, at first i
 thought might be this is causing issue, but i tried to use
 SO_EXCLUSIVEADDRUSE even then it dont work.

Has someone seen some issue like this, any possible suggestion for
 this?

 Thanks,

 // Harshvir


 http://www.catb.org/~esr/faqs/smart-questions.html










Re: Multiple connection from 1 client

2011-05-06 Thread Eric S. Eberhard

Change the sockets.  This is what I use:

int setblock(fd, mode)
int fd;
int mode;   /* True - blocking, False - non blocking */
{
int flags;
int prevmode;

flags = fcntl(fd, F_GETFL, 0);
prevmode = !(flags  O_NDELAY);
if (mode)
flags = ~O_NDELAY; /* turn blocking on */
else
flags |= O_NDELAY;  /* turn blocking off */
fcntl(fd, F_SETFL, flags);

return prevmode;
}

Since it returns the existing mode you can use as such:

prevmode = setblock(fd,0)   /* turn of blocking */
/* do your thing */
(void)setblock(fd,prevmode);/* restore to 
original condition */


At 04:15 PM 5/6/2011, you wrote:

Thanks for the reply Gayathri.
Do you mean to changing the sockets to non blocking, or when i 
create bio for ssl to make that as non blocking?


Thanks.

On Fri, May 6, 2011 at 6:03 PM, Gayathri Sundar 
mailto:suraj...@gmail.comsuraj...@gmail.com wrote:

Harsh,

Okay from what I can understand, if you make ur underlying fd non 
blocking then it would work fine. Blocking FDs, unless and until one 
client is finished with its processing the other client will not be 
able to communicate with the server as the previous fd is blocked. 
The server is waiting on the 1st client to finish. When you have 3 
ports and 3 clients then ofcourse it will work.


thanks
--Gayathri


On Fri, May 6, 2011 at 5:50 PM, Harshvir Sidhu 
mailto:hvssi...@gmail.comhvssi...@gmail.com wrote:

Gayatri,
My server code is single threaded and i am using blocking sockets, i 
am using fd_set and select to wait for event on socket, and then 
performing operation based on the event that acts on a socket.
I have an array of sockets to listen. So if i start listening on 3 
different ports and from my client machien, i try to connect on them 
at different ports then it works fine, but when i use 1 listen port 
then it dont work properly. What i mean to say by work properly is 
that the connection is established, but when i am waiting for select 
to return event, then it dont show any activity when i send data 
from client, only 1 of them works, 2 dont work.
In addition to that, when i use WireShark to see packets, then it 
shows that machine has received the packet from client. But server 
dont show that alert.

Thats why i think it could be some socket option which is affecting it.

// Harshvir


On Fri, May 6, 2011 at 5:37 PM, Gayathri Sundar 
mailto:suraj...@gmail.comsuraj...@gmail.com wrote:

Harshvir,

SO_REUSEADDR sock option has noting to do with ur problem, please go 
thro the socket ops man page to get a better understanding. First 
find out if ur server code is a blocking i/o or non blocking I/O..if 
former then connections will be handled sequentially..only after the 
1st client is finished will the server be able to respond to the 2nd 
connect request. If non blocking then there should be no problem. 
Check the code if you see and O_NONBLOCK flag set in some fcntl call 
or check for FIONBIO flag.


Thanks
--Gayathri


On Fri, May 6, 2011 at 5:29 PM, Harshvir Sidhu 
mailto:hvssi...@gmail.comhvssi...@gmail.com wrote:

Well i think this link is for my question.
I have already done 1-5 from the Before you ask list.
Number 6, i dont know anyone who use openssl.
Number 7, it will take a lot of time to go through all the code, i 
was just trying to save some time. I thought user discussion forums 
are for this only. I apologize for my understanding.



On Fri, May 6, 2011 at 5:18 PM, Jeremy Farrell 
mailto:jfarr...@pillardata.comjfarr...@pillardata.com wrote:



From: Harshvir Sidhu

Hi,

   I have a server application, which accepts normal sockets and 
ssl socket connections. I am trying to make 3 connections to server 
from 1 client machine, on same server port.
   When i connect on normal sockets then it works with any number 
of connections.
   When i tried to connect SSL then they dont work. If i connect 1 
client then it works.


   In my listen socket, I have SO_REUSEADDR socket option, at first 
i thought might be this is causing issue, but i tried to use 
SO_EXCLUSIVEADDRUSE even then it dont work.


   Has someone seen some issue like this, any possible suggestion for this?

Thanks,

// Harshvir


http://www.catb.org/~esr/faqs/smart-questions.htmlhttp://www.catb.org/~esr/faqs/smart-questions.html










Eric S. Eberhard
(928) 567-3727  Voice
(928) 567-6122  Fax
(928) 301-7537   Cell

Vertical Integrated Computer Systems, LLC
Metropolis Support, LLC

For Metropolis support and VICS MBA Supporthttp://www.vicsmba.com

Pictures of Snake in Spring

http://www.facebook.com/album.php?aid=115547id=1409661701l=1c375e1f49

Pictures of Camp Verde

http://www.facebook.com/album.php?aid=12771id=1409661701l=fc0e0a2bcf

Pictures of Land Cruiser in Sedona

http://www.facebook.com/album.php?aid=50953id=1409661701

Pictures of 

Re: Multiple connection from 1 client

2011-05-06 Thread Gayathri Sundar
Yes, you need to make the underlying socket non blocking, and at the
same time gotta change the way you call SSL_accept, SSL_read, write
etc to handle non block error conditions like want_read, want_write
errors, use the code Eric has given to make the fd non block, or u can
also set the bio non block by using FIONBIO option. basically you
really need to write an asynchronous state machine.

Thanks
--Gayathri

On Friday, May 6, 2011, Harshvir Sidhu hvssi...@gmail.com wrote:
 Thanks for the reply Gayathri.Do you mean to changing the sockets to non 
 blocking, or when i create bio for ssl to make that as non blocking?
 Thanks.
 On Fri, May 6, 2011 at 6:03 PM, Gayathri Sundar suraj...@gmail.com wrote:
 Harsh,
 Okay from what I can understand, if you make ur underlying fd non blocking 
 then it would work fine. Blocking FDs, unless and until one client is 
 finished with its processing the other client will not be able to communicate 
 with the server as the previous fd is blocked. The server is waiting on the 
 1st client to finish. When you have 3 ports and 3 clients then ofcourse it 
 will work.


 thanks--Gayathri

 On Fri, May 6, 2011 at 5:50 PM, Harshvir Sidhu hvssi...@gmail.com wrote:
 Gayatri,My server code is single threaded and i am using blocking sockets, i 
 am using fd_set and select to wait for event on socket, and then performing 
 operation based on the event that acts on a socket.

 I have an array of sockets to listen. So if i start listening on 3 different 
 ports and from my client machien, i try to connect on them at different ports 
 then it works fine, but when i use 1 listen port then it dont work properly. 
 What i mean to say by work properly is that the connection is established, 
 but when i am waiting for select to return event, then it dont show any 
 activity when i send data from client, only 1 of them works, 2 dont work.


 In addition to that, when i use WireShark to see packets, then it shows that 
 machine has received the packet from client. But server dont show that 
 alert.Thats why i think it could be some socket option which is affecting it.



 // Harshvir

 On Fri, May 6, 2011 at 5:37 PM, Gayathri Sundar suraj...@gmail.com wrote:
 Harshvir,
 SO_REUSEADDR sock option has noting to do with ur problem, please go thro the 
 socket ops man page to get a better understanding. First find out if ur 
 server code is a blocking i/o or non blocking I/O..if former then connections 
 will be handled sequentially..only after the 1st client is finished will the 
 server be able to respond to the 2nd connect request. If non blocking then 
 there should be no problem. Check the code if you see and O_NONBLOCK flag set 
 in some fcntl call or check for FIONBIO flag.




 Thanks--Gayathri

 On Fri, May 6, 2011 at 5:29 PM, Harshvir Sidhu hvssi...@gmail.com wrote:
 Well i think this link is for my question.I have already done 1-5 from the 
 Before you ask list.Number 6, i dont know anyone who use openssl.



 Number 7, it will take a lot of time to go through all the code, i was just 
 trying to save some time. I thought user discussion forums are for this only. 
 I apologize for my understanding.


 On Fri, May 6, 2011 at 5:18 PM, Jeremy Farrell jfarr...@pillardata.com 
 wrote:












   From: Harshvir Sidhu



   Hi,

      I have a server application, which accepts normal sockets
   and ssl socket connections. I am trying to make 3 connections to server
   from 1 client machine, on same server port.
      When i connect on normal sockets then it works with any
   number of connections.
      When i tried to connect SSL then they dont work. If i
   connect 1 client then it works.

      In my listen socket, I have SO_REUSEADDR
   socket option, at first i thoug
__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


Re: Multiple connection from 1 client

2011-05-06 Thread Harshvir Sidhu
Thanks, I will give this a try.

// Harshvir

On Fri, May 6, 2011 at 6:44 PM, Eric S. Eberhard fl...@vicsmba.com wrote:

 Change the sockets.  This is what I use:

 int setblock(fd, mode)
 int fd;
 int mode;   /* True - blocking, False - non blocking */
 {
int flags;
int prevmode;

flags = fcntl(fd, F_GETFL, 0);
prevmode = !(flags  O_NDELAY);
if (mode)
flags = ~O_NDELAY; /* turn blocking on */
else
flags |= O_NDELAY;  /* turn blocking off */
fcntl(fd, F_SETFL, flags);

return prevmode;
 }

 Since it returns the existing mode you can use as such:

 prevmode = setblock(fd,0)   /* turn of blocking */
 /* do your thing */
 (void)setblock(fd,prevmode);/* restore to original
 condition */


 At 04:15 PM 5/6/2011, you wrote:

 Thanks for the reply Gayathri.
 Do you mean to changing the sockets to non blocking, or when i create bio
 for ssl to make that as non blocking?

 Thanks.

 On Fri, May 6, 2011 at 6:03 PM, Gayathri Sundar mailto:
 suraj...@gmail.comsuraj...@gmail.com wrote:
 Harsh,

 Okay from what I can understand, if you make ur underlying fd non blocking
 then it would work fine. Blocking FDs, unless and until one client is
 finished with its processing the other client will not be able to
 communicate with the server as the previous fd is blocked. The server is
 waiting on the 1st client to finish. When you have 3 ports and 3 clients
 then ofcourse it will work.

 thanks
 --Gayathri


 On Fri, May 6, 2011 at 5:50 PM, Harshvir Sidhu mailto:
 hvssi...@gmail.comhvssi...@gmail.com wrote:
 Gayatri,
 My server code is single threaded and i am using blocking sockets, i am
 using fd_set and select to wait for event on socket, and then performing
 operation based on the event that acts on a socket.
 I have an array of sockets to listen. So if i start listening on 3
 different ports and from my client machien, i try to connect on them at
 different ports then it works fine, but when i use 1 listen port then it
 dont work properly. What i mean to say by work properly is that the
 connection is established, but when i am waiting for select to return event,
 then it dont show any activity when i send data from client, only 1 of them
 works, 2 dont work.
 In addition to that, when i use WireShark to see packets, then it shows
 that machine has received the packet from client. But server dont show that
 alert.
 Thats why i think it could be some socket option which is affecting it.

 // Harshvir


 On Fri, May 6, 2011 at 5:37 PM, Gayathri Sundar mailto:
 suraj...@gmail.comsuraj...@gmail.com wrote:
 Harshvir,

 SO_REUSEADDR sock option has noting to do with ur problem, please go thro
 the socket ops man page to get a better understanding. First find out if ur
 server code is a blocking i/o or non blocking I/O..if former then
 connections will be handled sequentially..only after the 1st client is
 finished will the server be able to respond to the 2nd connect request. If
 non blocking then there should be no problem. Check the code if you see and
 O_NONBLOCK flag set in some fcntl call or check for FIONBIO flag.

 Thanks
 --Gayathri


 On Fri, May 6, 2011 at 5:29 PM, Harshvir Sidhu mailto:
 hvssi...@gmail.comhvssi...@gmail.com wrote:
 Well i think this link is for my question.
 I have already done 1-5 from the Before you ask list.
 Number 6, i dont know anyone who use openssl.
 Number 7, it will take a lot of time to go through all the code, i was
 just trying to save some time. I thought user discussion forums are for this
 only. I apologize for my understanding.


 On Fri, May 6, 2011 at 5:18 PM, Jeremy Farrell mailto:
 jfarr...@pillardata.comjfarr...@pillardata.com wrote:


 From: Harshvir Sidhu

 Hi,

   I have a server application, which accepts normal sockets and ssl socket
 connections. I am trying to make 3 connections to server from 1 client
 machine, on same server port.
   When i connect on normal sockets then it works with any number of
 connections.
   When i tried to connect SSL then they dont work. If i connect 1 client
 then it works.

   In my listen socket, I have SO_REUSEADDR socket option, at first i
 thought might be this is causing issue, but i tried to use
 SO_EXCLUSIVEADDRUSE even then it dont work.

   Has someone seen some issue like this, any possible suggestion for this?

 Thanks,

 // Harshvir


 http://www.catb.org/~esr/faqs/smart-questions.html
 http://www.catb.org/~esr/faqs/smart-questions.html









 Eric S. Eberhard
 (928) 567-3727  Voice
 (928) 567-6122  Fax
 (928) 301-7537   Cell

 Vertical Integrated Computer Systems, LLC
 Metropolis Support, LLC

 For Metropolis support and VICS MBA Supporthttp://www.vicsmba.com

 Pictures of Snake in Spring

 http://www.facebook.com/album.php?aid=115547id=1409661701l=1c375e1f49

 Pictures of Camp Verde

 

Re: Multiple connection from 1 client

2011-05-06 Thread Gayathri Sundar
Harsh.,

If u have any specific doubts in writing this asynchronous state
machine email me privately at suraj...@gmail.com.
I am pretty much jobless right now and can spend some time on this.

Thanks
--Gayathri


On Friday, May 6, 2011, Harshvir Sidhu hvssi...@gmail.com wrote:
 Thanks, I will give this a try.
 // Harshvir

 On Fri, May 6, 2011 at 6:44 PM, Eric S. Eberhard fl...@vicsmba.com wrote:
 Change the sockets.  This is what I use:

 int setblock(fd, mode)
 int fd;
 int mode;                       /* True - blocking, False - non blocking */
 {
         int flags;
         int prevmode;

         flags = fcntl(fd, F_GETFL, 0);
         prevmode = !(flags  O_NDELAY);
         if (mode)
                 flags = ~O_NDELAY;             /* turn blocking on */
         else
                 flags |= O_NDELAY;              /* turn blocking off */
         fcntl(fd, F_SETFL, flags);

         return prevmode;
 }

 Since it returns the existing mode you can use as such:

 prevmode = setblock(fd,0)                       /* turn of blocking */
 /* do your thing */
 (void)setblock(fd,prevmode);                    /* restore to original 
 condition */

 At 04:15 PM 5/6/2011, you wrote:

 Thanks for the reply Gayathri.
 Do you mean to changing the sockets to non blocking, or when i create bio for 
 ssl to make that as non blocking?

 Thanks.


 On Fri, May 6, 2011 at 6:03 PM, Gayathri Sundar 
 mailto:suraj...@gmail.comsuraj...@gmail.com wrote:
 Harsh,

 Okay from what I can understand, if you make ur underlying fd non blocking 
 then it would work fine. Blocking FDs, unless and until one client is 
 finished with its processing the other client will not be able to communicate 
 with the server as the previous fd is blocked. The server is waiting on the 
 1st client to finish. When you have 3 ports and 3 clients then ofcourse it 
 will work.

 thanks
 --Gayathri



 On Fri, May 6, 2011 at 5:50 PM, Harshvir Sidhu 
 mailto:hvssi...@gmail.comhvssi...@gmail.com wrote:
 Gayatri,
 My server code is single threaded and i am using blocking sockets, i am using 
 fd_set and select to wait for event on socket, and then performing operation 
 based on the event that acts on a socket.
 I have an array of sockets to listen. So if i start listening on 3 different 
 ports and from my client machien, i try to connect on them at different ports 
 then it works fine, but when i use 1 listen port then it dont work properly. 
 What i mean to say by work properly is that the connection is established, 
 but when i am waiting for select to return event, then it dont show any 
 activity when i send data from client, only 1 of them works, 2 dont work.
 In addition to that, when i use WireShark to see packets, then it shows that 
 machine has received the packet from client. But server dont show that alert.
 Thats why i think it could be some socket option which is affecting it.

 // Harshvir



 On Fri, May 6, 2011 at 5:37 PM, Gayathri Sundar 
 mailto:suraj...@gmail.comsuraj...@gmail.com wrote:
 Harshvir,

 SO_REUSEADDR sock option has noting to do with ur problem, please go thro the 
 socket ops man page to get a better understanding. First find out if ur 
 server code is a blocking i/o or non blocking I/O..if former then connections 
 will be handled sequentially..only after the 1st client is finished will the 
 server be able to respond to the 2nd connect request. If non blocking then 
 there should be no problem. Check the code if you see and O_NONBLOCK flag set 
 in some fcntl call or check for FIONBIO flag.

 Thanks
 --Gayathri



 On Fri, May 6, 2011 at 5:29 PM, Harshvir Sidhu 
 mailto:hvssi...@gmail.comhvssi...@gmail.com wrote:
 Well i think this link is for my question.
 I have already done 1-5 from the Before you ask list.
 Number 6, i dont know anyone who use openssl.
 Number 7, it will take a lot of time to go through all the code, i was just 
 trying to save some time. I thought user discussion forums are for this only. 
 I apologize for my understanding.

__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org