[En-Nut-Discussion] More clients on the same TCP port

José Vallet jose.vallet at hut.fi
Fri Sep 29 10:30:52 CEST 2006


def at fea.kiev.ua wrote:
>> Hello
>>
>> ZIP wrote:
>>> Hello,
>>>
>>>  Could you please give me a hint how to implement a server, which serves
>>> on the same port for more ethernet clients.
>> From
>> http://www.ethernut.de/api/index.html
>>
>> ************************
>> The order of API calls for TCP servers is
>>
>>      * NutTcpCreateSocket()
>>      * NutTcpAccept()
>>      * NutTcpSend(), NutTcpReceive()
>>      * NutTcpCloseSocket()
>>
>> Note, that this differs slightly from the Berkley API, where the initial
>> socket is bound to a port and an additional socket is created when a
>> connection is accepted. Nut/Net doesn't provide a bind call.
>> *************************
>>
>> As far as I understand this, once a server socker accepts one incoming
>> connection you cannot use that socket to listen for more incoming
>> connections. But I am not an expert here.
>>> Is it possible to have NutTcpAccept on created socket at the beggining
>>> of a thread a then starts new thread for this socket, which receives
>>> text commands and proceeds them and may-be send replies ?
>> I think so, as long as you are able to make the socket visible to the
>> new thread. However, as I told you before, I think that that socket will
>> not accept any other incoming connection, no matter what thread you are
>> using it from.
>>
>> Please, some guru correct me...
>>> I need to accept more connections before all the commands are proceeded.
>> I would use different ports. I ignore other solution here.
>>
> Hmmm....
> nutapp/httpd ????

Here we have 5 threads each one running its own http server, and each 
thread with its own socket, all of them listening to port 80. Am I 
right? (don't know much about TCP internals) Is this your point?

José




More information about the En-Nut-Discussion mailing list