lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Re: More help with socket


From: Oscar F
Subject: Re: [lwip-users] Re: More help with socket
Date: Wed, 9 Sep 2009 08:57:19 +0200

thanks Mathias, i´d like to create only one task, because only three socket i need to read, the rest is only for answer. In my case the customer said to me:

                        Requeest:

                        -           RQ-R-1 Port Number = 1500H           (=  5376 dec)

                        -           RQ-R-2 Port Number = 1501H           (=  5377 dec)

                        -           RQ-R-3 Port Number = 1502H           (=  5378 dec)

 

                        Answer:

                        -           RP-R-1 Port Number = 1600H           (=  5632 dec)

                        -           RP-R-2 Port Number = 1601H           (=  5633 dec)

                        -           RP-R-3 Port Number = 1602H           (=  5634 dec)

                        -           the application in EVK1100 Internet address shall be fixed to : 192.168.5.248

When i´ve received a request always i  have to answerd for other socket, example i recived RQ-R-1 and i need to answer ACK for RP-R-1.
If i use 6 task, i´ll need to syncronice, and communicate intertask, and i not sure if that solution is more difficult. On the other hand i need to create only task, i´ll need to accept the 6 socket connections sequentially ( the customer said me :
connect sequentially (one after the other) all the logical links.), i supossed that each accept coenction is blocking.
Then i´d like tu use (select function) for three socket to wait data for RQ-R-1, or RQ-R-2 or RQ-R-3, because select is a function blocking too.

I don´t know, if i can implement my idea, but i think is more easier. do you think Mathias that my solution can be implemented?

If i can´t use this method, i ´ll need to use the six socket, i should to create 6 task waiting for accept conecction, and then use three task to answer (the RP-R-X) blocking with a semaphore, and the other task blocking with a function to receive data from PC ż
lwip_recv can be used or need another función to wait a data for PC blocking the task and let to the other task are running? in the example http://www.ultimaserial.com/classroom2.html i supposed that the while (1) always enter and no blocking the task to wait for data.

Thank again, it´s a pleasure for me your help.but i don´t knows what implementation i should use......
Regards

Oscar


On Wed, Sep 9, 2009 at 8:15 AM, Mathias Zenger <address@hidden> wrote:
Some thoughts:
 
Your application should accept incoming requests so let's call it the server. I would suggest to start out with a single TCP connection to get familiar with the topic. As a simple example you could use the TCP echo server (socket programming) found at http://www.ultimaserial.com/classroom2.html
 
What your server task basically needs:
 
- implement a new task
- create a socket: socket()
- bind it to the local address: bind()
- set socket to listen mode: listen()
- accept incoming requests: accept()
- answer the request: send()
 
As soon as you get the example working you can go ahead with the other connections. Either you implement a seperate task for each socket you need or you could start more than one instance of the above task (e.g. pass the internet address and socket number as function parameters to your portTASK_FUNCTION).
 
To get familiar with FreeRTOS I recommend to purchase and read Richard Barry's book (http://www.freertos.org/Documentation/FreeRTOS-documentation-and-book.html)
Some information to get familiar with the BSD sockets interface from a link found at lwIP Wiki (http://docs.hp.com/en/B2355-90136/)
 
Regards,
Mathias
 
 
-----Ursprüngliche Nachricht-----
Von: lwip-users-bounces+m.zenger=mobatime.com@nongnu.org [mailto:lwip-users-bounces+m.zenger=mobatime.com@nongnu.org]Im Auftrag von Oscar F
Gesendet: Dienstag, 8. September 2009 20:12
An: Mailing list for lwIP users
Betreff: [lwip-users] Re: More help with socket

The second part is not correct because always my task have the control and another task never enter.
can i use the select option? with TCP connection and another idea to listen about three socket and blocking while there isn´t data?

Thanks again
Oscar



On Tue, Sep 8, 2009 at 7:59 PM, Oscar F <address@hidden> wrote:
I know more data about the application. The connection is TCP, and i have to open 6 socket, all of them unidirectional , 3 for request and 3 for response.

Logical links connection sequence

logical links connection process shall be initiated by the PC unit: it will connect sequentially (one after the other) all the logical links.

At power-on/reset, the EVK1100 application shall first create the sockets in order to be ready for accepting a connection in all of them.


my first question is the function accept is blocking the code, because i´ll do of this way


-createsockets( ) (the six socket)

-bind( ) the six socket

-listen ( ) the six socket


and then

do {


-accept ( ) for socket one

if the answer is OK

-accept () for the second one

if the answer is OK

...

-accept () for the six one

if the answer is OK then fin=true



}while (fin)


 

is that correct?


the next step is listen for 3 socket to request and this is my idea:



do{


if recv(socke1)

 {

  //process


}


if recv(socket2)

 {

  //process


}



if recv(socket3)

 {

  //process


}



}while (fin2)


is a good idea?


thanks for all

Oscar




_______________________________________________
lwip-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users


reply via email to

[Prev in Thread] Current Thread [Next in Thread]