This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
sdk:tcp2sms [2015/07/03 09:00] – fachet | sdk:tcp2sms [2017/10/23 16:45] (current) – fachet | ||
---|---|---|---|
Line 3: | Line 3: | ||
* Don't forget to configure and enable the SMS service first | * Don't forget to configure and enable the SMS service first | ||
* The number format is international e.g. +4912345678 | * The number format is international e.g. +4912345678 | ||
- | * Copyright (C) 2012 NetModule AG, Switzerland | + | * |
+ | * Copyright (C) 2017 NetModule AG, Switzerland | ||
*/ | */ | ||
- | port = 2000; | ||
- | if ((s = socket(AF_INET, | + | PORT = 2000; |
- | if (bind(s, port, "" | + | |
- | if (listen(s, 1) == -1) exit(3); | + | |
- | for(;;) { | + | if ((s = socket(AF_INET, SOCK_STREAM, |
- | | + | exit(1); |
- | for(;;) { | + | if (bind(s, PORT, "" |
- | if ((r = select(c, 10)) == - 1) exit(4); | + | |
- | if (r == 0) continue; | + | if (listen(s, 1) == -1) |
- | m = recv(c); | + | exit(3); |
- | if (p = strchr(m, ":" | + | |
- | if (nb_sms_send(left(m, | + | |
- | send(c, " | + | |
- | else | + | |
- | | + | |
- | } | + | |
- | } | + | |
+ | while (true) { | ||
+ | if (c = accept(s)) { | ||
+ | while (true) { | ||
+ | if ((r = select(c, 10)) == - 1) | ||
+ | exit(4); | ||
+ | if (r == 0) | ||
+ | continue; | ||
+ | m = recv(c); | ||
+ | if (p = strchr(m, ":" | ||
+ | if (nb_sms_send(left(m, | ||
+ | send(c, " | ||
+ | else | ||
+ | send(c, " | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | /* not reached */ | ||
</ | </ |