demo versie 16/05
Dependencies: EthernetInterface mbed-rto mbed
Fork of ProjectVLC by
TCPlistener.cpp@23:28e41b1c8a71, 2018-04-25 (annotated)
- Committer:
- KlaasGovaerts
- Date:
- Wed Apr 25 08:10:54 2018 +0000
- Revision:
- 23:28e41b1c8a71
- Parent:
- 21:fe6a58e84929
- Child:
- 25:4c673da1a3ae
- Child:
- 31:915f6cb7ffa5
Nieuw ip adres
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(){ |
KlaasGovaerts | 23:28e41b1c8a71 | 4 | char ip[]="172.16.1.253"; |
KlaasGovaerts | 23:28e41b1c8a71 | 5 | char mask[]="255.255.0.0"; |
KlaasGovaerts | 23:28e41b1c8a71 | 6 | char gateway[]="172.16.0.1"; |
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(); |
KlaasGovaerts | 20:4997b02d6a88 | 11 | server.set_blocking(true); |
KlaasGovaerts | 15:5f1fda6b9140 | 12 | arraySize=10; |
KlaasGovaerts | 5:0413d42377d1 | 13 | } |
KlaasGovaerts | 13:f3db7045e220 | 14 | |
KlaasGovaerts | 16:ffd311730575 | 15 | bool TCPlistener::receiveSegment(char *contents,int size){ |
KlaasGovaerts | 20:4997b02d6a88 | 16 | printf("Maak een connectie.\r\n"); |
KlaasGovaerts | 20:4997b02d6a88 | 17 | TCPSocketConnection client; |
KlaasGovaerts | 20:4997b02d6a88 | 18 | server.accept(client); |
KlaasGovaerts | 20:4997b02d6a88 | 19 | int n=client.receive(contents,size); |
KlaasGovaerts | 20:4997b02d6a88 | 20 | if(n!=-1){ |
KlaasGovaerts | 20:4997b02d6a88 | 21 | contents[n] = '\0'; |
KlaasGovaerts | 20:4997b02d6a88 | 22 | printf("Segment ontvangen van %s:%i met inhoud \"%s\"\r\n", client.get_address(),client.get_port(),contents); |
KlaasGovaerts | 20:4997b02d6a88 | 23 | return true; |
KlaasGovaerts | 16:ffd311730575 | 24 | } |
KlaasGovaerts | 16:ffd311730575 | 25 | return false; |
KlaasGovaerts | 19:5ee34e60a31d | 26 | } |