server/client
Dependencies: mbed NetServicesMin
main.cpp@0:432b571e11a3, 2012-02-19 (annotated)
- Committer:
- recotana
- Date:
- Sun Feb 19 06:21:50 2012 +0000
- Revision:
- 0:432b571e11a3
- Child:
- 1:6e61ee662fd3
ver0.1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
recotana | 0:432b571e11a3 | 1 | #include "mbed.h" |
recotana | 0:432b571e11a3 | 2 | #include "EthernetNetIf.h" |
recotana | 0:432b571e11a3 | 3 | #include "config.h" |
recotana | 0:432b571e11a3 | 4 | #include "tcp_server.h" |
recotana | 0:432b571e11a3 | 5 | #include "tcp_client.h" |
recotana | 0:432b571e11a3 | 6 | |
recotana | 0:432b571e11a3 | 7 | EthernetNetIf eth ; |
recotana | 0:432b571e11a3 | 8 | |
recotana | 0:432b571e11a3 | 9 | Ticker connectCheck; |
recotana | 0:432b571e11a3 | 10 | |
recotana | 0:432b571e11a3 | 11 | int main() { |
recotana | 0:432b571e11a3 | 12 | |
recotana | 0:432b571e11a3 | 13 | |
recotana | 0:432b571e11a3 | 14 | EthernetNetIf eth( //) -- static IP address |
recotana | 0:432b571e11a3 | 15 | IpAddr(kSserverIp), // IP Address |
recotana | 0:432b571e11a3 | 16 | IpAddr(kSubnetMask), // Subnet Mask |
recotana | 0:432b571e11a3 | 17 | IpAddr(kRouterIp), // Default Gateway |
recotana | 0:432b571e11a3 | 18 | IpAddr(kRouterIp) // DNS Server |
recotana | 0:432b571e11a3 | 19 | ) ; |
recotana | 0:432b571e11a3 | 20 | |
recotana | 0:432b571e11a3 | 21 | if( eth.setup() != ETH_OK ) |
recotana | 0:432b571e11a3 | 22 | { |
recotana | 0:432b571e11a3 | 23 | printf("Ether Setup Error\r\n"); |
recotana | 0:432b571e11a3 | 24 | return -1; |
recotana | 0:432b571e11a3 | 25 | } |
recotana | 0:432b571e11a3 | 26 | printf("Setup OK\r\n"); |
recotana | 0:432b571e11a3 | 27 | |
recotana | 0:432b571e11a3 | 28 | IpAddr ip = eth.getIp() ; |
recotana | 0:432b571e11a3 | 29 | printf("mbed IP Address is [%d.%d.%d.%d]\r\n", ip[0], ip[1], ip[2], ip[3]) ; |
recotana | 0:432b571e11a3 | 30 | |
recotana | 0:432b571e11a3 | 31 | serverInit(); |
recotana | 0:432b571e11a3 | 32 | |
recotana | 0:432b571e11a3 | 33 | clientInit(); |
recotana | 0:432b571e11a3 | 34 | connectCheckStart( IpAddr(kClientIp),kClientPort ); |
recotana | 0:432b571e11a3 | 35 | |
recotana | 0:432b571e11a3 | 36 | while(1) { |
recotana | 0:432b571e11a3 | 37 | Net::poll(); |
recotana | 0:432b571e11a3 | 38 | } |
recotana | 0:432b571e11a3 | 39 | } |