![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
demo versie 16/05
Dependencies: EthernetInterface mbed-rto mbed
Fork of ProjectVLC by
TCPlistener.cpp@67:0b634db67ca8, 2018-05-09 (annotated)
- Committer:
- KlaasGovaerts
- Date:
- Wed May 09 15:13:40 2018 +0000
- Revision:
- 67:0b634db67ca8
- Parent:
- 62:237e32fd3555
Nog verder opgekuist.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
KlaasGovaerts | 5:0413d42377d1 | 1 | #include "TCPlistener.h" |
KlaasGovaerts | 5:0413d42377d1 | 2 | |
KlaasGovaerts | 5:0413d42377d1 | 3 | TCPlistener::TCPlistener(){ |
albireo987 | 25:4c673da1a3ae | 4 | char ip[]="192.168.0.253"; |
albireo987 | 25:4c673da1a3ae | 5 | char mask[]="255.255.255.0"; |
KlaasGovaerts | 31:915f6cb7ffa5 | 6 | char gateway[]="192.168.0.254"; |
KlaasGovaerts | 5:0413d42377d1 | 7 | eth.init(ip,mask,gateway); |
KlaasGovaerts | 5:0413d42377d1 | 8 | eth.connect(); |
KlaasGovaerts | 5:0413d42377d1 | 9 | server.bind(4000); |
KlaasGovaerts | 16:ffd311730575 | 10 | server.listen(); |
albireo987 | 38:47c075a354b5 | 11 | server.set_blocking(true); |
KlaasGovaerts | 5:0413d42377d1 | 12 | } |
KlaasGovaerts | 13:f3db7045e220 | 13 | |
KlaasGovaerts | 16:ffd311730575 | 14 | bool TCPlistener::receiveSegment(char *contents,int size){ |
KlaasGovaerts | 20:4997b02d6a88 | 15 | printf("Maak een connectie.\r\n"); |
KlaasGovaerts | 20:4997b02d6a88 | 16 | TCPSocketConnection client; |
KlaasGovaerts | 20:4997b02d6a88 | 17 | server.accept(client); |
albireo987 | 32:537005b4a065 | 18 | int n=client.receive(contents,size); |
albireo987 | 38:47c075a354b5 | 19 | if(n!=-1){ |
albireo987 | 32:537005b4a065 | 20 | contents[n] = '\0'; |
albireo987 | 32:537005b4a065 | 21 | printf("Segment ontvangen van %s:%i met inhoud \"%s\"\r\n", client.get_address(),client.get_port(),contents); |
albireo987 | 32:537005b4a065 | 22 | return true; |
albireo987 | 32:537005b4a065 | 23 | } |
KlaasGovaerts | 16:ffd311730575 | 24 | return false; |
KlaasGovaerts | 19:5ee34e60a31d | 25 | } |