[erlang-questions] TCP/IP socket communication problem

Surindar Sivanesan <>
Wed Jan 17 06:30:23 CET 2007


Dear Joe,

The application is a huge one and could not be sent through mail.
So, I have pasted the part of the code where I face error...

server_connection(ListeningSocket)->
 ConnectionResult=gen_tcp:accept(ListeningSocket),
 case ConnectionResult of
    {ok,AcceptedSocket}->
     spawn(identify_client,receive_request,[ConnectionResult]),
     server_connection(ListeningSocket);
    {error,Reason}->
      io:fwrite("Reason for error in accepting socket is ~p\n",[Reason]);
       ListenResult=gen_tcp:listen(get(port),[list,{backlog,210},{packet,
0},{active, false}]),
       case ListenResult of
        {ok,ListenSocket1}->
          server_connection(ListenSocket1);
         {error,Reason1}->
          io:fwrite("Reason for error in second listen is ~p\n",[Reason1]);
         _->
          io:fwrite("Some other error in listening in server_connection1\n")
        end
   _->
    io:fwrite("Some other error in listening in server_connection2\n")
  end.
This server_connection function continues to listen in the 'ListeningSocket'
provided by a parent module. If any client is connecting, this function will
spawn a process with that socket to receive the messages from the client.
Like wise, 50 clients have established communication and the messages are
transmitted to and fro. At some point of time, the gen_tcp:accept/1 function
returns {error,enfile} and all the 50 client server communication are
closed. When the server_connection function tends to listen socket again
using gen_tcp:listen/2, again an error is occurred. Please let me know if
you find any clue regarding this problem.

Regards,
S.Surindar.

On 1/16/07, Joe Armstrong <> wrote:
>
> You have not sent any code, it is impossible to answer your question if
> you have
> don't send the code that you suspect is not working correctly.
>
> If you post the code then we can try running in on a different OS
> to see if we can reproduce the problem.
>
> /Joe
>
>
>  On 1/14/07, Surindar Sivanesan <  > wrote:
>
> >  Dear all,
> >
> > We are using an application in erlang which is acting as a server. This
> > server is continuously listening and ready to accept any client in TCP/IP
> > communication.
> > Around *50 clients* connecting with this server application. This
> > application is working fine for some time.
> > At one point of time, while the server is accepting a communication
> > using the BIF *gen_tcp:accept/1*, *{error,enfile}* error is occurred and
> > *all the 50 clients using that socket are disconnected abruptly*.
> > We are using Windows 2003 server OS and Erlang *ERTS **5.5*.
> >
> > Please provide me the solution if any to solve this problem
> >
> > Thanks in advance
> >
> > --
> > with regards,
> > S.Surindar
> >
> > _______________________________________________
> > erlang-questions mailing list
> > 
> > http://www.erlang.org/mailman/listinfo/erlang-questions
> >
> >
> >
>


-- 
with regards,
S.Surindar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20070117/7132c12a/attachment.html>


More information about the erlang-questions mailing list