PageRenderTime 54ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/pilot-link-0.12.5/include/pi-socket.h

#
C Header | 579 lines | 158 code | 55 blank | 366 comment | 0 complexity | c929569627d78f0ad41dfef90dd0034e MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0
  1. /*
  2. * $Id: pi-socket.h,v 1.72 2006/10/17 13:24:07 desrod Exp $
  3. *
  4. * pi-socket.h: Socket-like interface to talk to handhelds
  5. *
  6. * This library is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU Library General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or (at
  9. * your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Library General Public License
  17. * along with this library; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. /** @file pi-socket.h
  21. * @brief Socket-like interface to talk to handhelds
  22. *
  23. * pi-socket is the root of the way you'll talk to a device. You'll first
  24. * create a socket using pi_socket(), then either use pi_bind(), pi_listen()
  25. * and pi_accept() to accept a connection, or pi_connect() to initiate a
  26. * network connection.
  27. *
  28. * A socket encapsulates the various protocol layers required to talk to the
  29. * handheld. You can access the various protocol levels using pi_protocol().
  30. *
  31. * Each protocol layer has options you can get and set using pi_getsockopt()
  32. * and pi_setsockopt().
  33. *
  34. * It is possible to read and write data using pi_read() and pi_write(),
  35. * though this usually not necessary. Instead, you will use the functions
  36. * from pi-dlp.h to talk to the device. They take care of all the low-level
  37. * stuff.
  38. *
  39. * At any time, you can check whether a connection is still established
  40. * using pi_socket_connected(). After each DLP call, you can call pi_error()
  41. * to check the latest error code. If the error code was #PI_ERR_DLP_PALMOS,
  42. * you should call pi_palmos_error() to retrieve the error code returned by
  43. * the device itself. See the pi-dlp.h documentation for more information.
  44. *
  45. * Finally, pi_version() returns the version of the DLP protocol on the
  46. * device. This can be used to check whether some features are supported,
  47. * such as VFS calls. See pi-dlp.h for more information.
  48. *
  49. * @see pi-dlp.h
  50. */
  51. #ifndef _PILOT_SOCKET_H_
  52. #define _PILOT_SOCKET_H_
  53. #include <unistd.h>
  54. #include "pi-args.h"
  55. #ifdef __cplusplus
  56. extern "C" {
  57. #endif
  58. #include "pi-version.h"
  59. #include "pi-sockaddr.h"
  60. #include "pi-buffer.h"
  61. #include "pi-error.h" /* For PI_ERR */
  62. #define PI_AF_PILOT 0x00
  63. #define PI_SOCK_STREAM 0x0010 /**< Stream socket type, for pi_socket() function */
  64. #define PI_SOCK_RAW 0x0030 /**< Raw socket type, for pi_socket() function */
  65. #define PI_CMD_CMP 0x01 /**< CMD command protocol type (for serial connections) */
  66. #define PI_CMD_NET 0x02 /**< NET protocol type (for inet and USB connections) */
  67. #define PI_CMD_SYS 0x03 /**< SYS protocol type (low-level, debugger connections) */
  68. #define PI_MSG_PEEK 0x01 /**< Use this flag with pi_recv() to 'peek' at the incoming data (will not be removed from input buffer) */
  69. /* deprecated (wasn't used)
  70. #define PI_MSG_REALLOC 0x02 */
  71. /** @brief Protocol types */
  72. enum PiProtocolTypes {
  73. PI_PF_DEV = 0x01, /**< Device-level protocol */
  74. PI_PF_SLP = 0x02, /**< Serial-level protocol */
  75. PI_PF_SYS = 0x03, /**< System-level protocol */
  76. PI_PF_PADP = 0x04, /**< PAD-level protocol */
  77. PI_PF_NET = 0x05, /**< NET-level protocol */
  78. PI_PF_DLP = 0x06 /**< DLP-level protocol */
  79. };
  80. /** @brief Protocol levels for the socket's protocol queue */
  81. enum PiOptLevels {
  82. PI_LEVEL_DEV, /**< Device level */
  83. PI_LEVEL_SLP, /**< Serial link protocol level */
  84. PI_LEVEL_PADP, /**< PADP protocol level */
  85. PI_LEVEL_NET, /**< NET protocol level */
  86. PI_LEVEL_SYS, /**< System protocol level */
  87. PI_LEVEL_CMP, /**< CMP protocol level */
  88. PI_LEVEL_DLP, /**< Desktop link protocol level*/
  89. PI_LEVEL_SOCK /**< Socket level */
  90. };
  91. /** @brief Device level socket options (use pi_getsockopt() and pi_setsockopt()) */
  92. enum PiOptDevice {
  93. PI_DEV_RATE,
  94. PI_DEV_ESTRATE,
  95. PI_DEV_HIGHRATE,
  96. PI_DEV_TIMEOUT
  97. };
  98. /** @brief Serial link protocol socket options (use pi_getsockopt() and pi_setsockopt()) */
  99. enum PiOptSLP {
  100. PI_SLP_DEST,
  101. PI_SLP_LASTDEST,
  102. PI_SLP_SRC,
  103. PI_SLP_LASTSRC,
  104. PI_SLP_TYPE,
  105. PI_SLP_LASTTYPE,
  106. PI_SLP_TXID,
  107. PI_SLP_LASTTXID
  108. };
  109. /** @brief PADP protocol socket options (use pi_getsockopt() and pi_setsockopt()) */
  110. enum PiOptPADP {
  111. PI_PADP_TYPE,
  112. PI_PADP_LASTTYPE,
  113. PI_PADP_FREEZE_TXID, /**< if set, don't increment txid when receiving a packet. Mainly used by dlp_VFSFileRead() */
  114. PI_PADP_USE_LONG_FORMAT /**< if set, use the long packet size format when transmitting */
  115. };
  116. /** @brief CMP protocol socket options (use pi_getsockopt() and pi_setsockopt()) */
  117. enum PiOptCMP {
  118. PI_CMP_TYPE,
  119. PI_CMP_FLAGS,
  120. PI_CMP_VERS,
  121. PI_CMP_BAUD
  122. };
  123. /** @brief NET protocol socket options (use pi_getsockopt() and pi_setsockopt()) */
  124. enum PiOptNet {
  125. PI_NET_TYPE,
  126. PI_NET_SPLIT_WRITES, /**< if set, write separately the NET header and data */
  127. PI_NET_WRITE_CHUNKSIZE /**< size of data chunks if PI_NET_SPLIT_WRITES is set. 0 for no chunking of data */
  128. };
  129. /** @brief Socket level options (use pi_getsockopt() and pi_setsockopt()) */
  130. enum PiOptSock {
  131. PI_SOCK_STATE, /**< Socket state (listening, closed, etc.) */
  132. PI_SOCK_HONOR_RX_TIMEOUT /**< Set to 1 to honor timeouts when waiting for data. Set to 0 to disable timeout (i.e. during dlp_CallApplication) */
  133. };
  134. struct pi_protocol; /* forward declaration */
  135. /** @brief Definition of a socket */
  136. typedef struct pi_socket {
  137. int sd; /**< Socket descriptor to pass to other functions */
  138. int type; /**< Socket type (i.e #PI_SOCK_STREAM) */
  139. int protocol; /**< Protocol (usually #PI_PF_DLP) */
  140. int cmd;
  141. struct sockaddr *laddr; /**< Socket local address */
  142. size_t laddrlen; /**< Local address length */
  143. struct sockaddr *raddr; /**< Socket remote address */
  144. size_t raddrlen; /**< Remote address length */
  145. struct pi_protocol **protocol_queue; /**< Ptr to the protocol queue */
  146. int queue_len; /**< Protocol queue length */
  147. struct pi_protocol **cmd_queue; /**< Ptr to the command queue */
  148. int cmd_len; /**< Command queue length */
  149. struct pi_device *device; /**< Low-level device we're talking to */
  150. int state; /**< Current socket state (initially #PI_SOCK_CLOSE). Use pi_setsockopt() with #PI_SOCK_STATE to set the state. */
  151. int honor_rx_to; /**< Honor packet reception timeouts. Set most to 1 of the time to have timeout management on incoming packets. Can be disabled when needed using pi_setsockopt() with #PI_SOCK_HONOR_RX_TIMEOUT. This is used, for example, to disable timeouts in dlp_CallApplication() so that lengthy tasks don't return an error. */
  152. int command; /**< true when socket in command state */
  153. int accept_to; /**< timeout value for call to accept() */
  154. int dlprecord; /**< Index used for some DLP functions */
  155. int dlpversion; /**< version of the DLP protocol running on the device */
  156. unsigned long maxrecsize; /**< max record size on the device */
  157. int last_error; /**< error code returned by the last dlp_* command */
  158. int palmos_error; /**< Palm OS error code returned by the last transaction with the handheld */
  159. } pi_socket_t;
  160. /** @brief Internal sockets chained list */
  161. typedef struct pi_socket_list
  162. {
  163. pi_socket_t *ps;
  164. struct pi_socket_list *next;
  165. } pi_socket_list_t;
  166. /** @name Socket management */
  167. /*@{*/
  168. /** @brief Create a new socket
  169. *
  170. * Call this function to allocate a new socket which you will later
  171. * bind to a specific port
  172. *
  173. * @param domain Not used. Set to 0.
  174. * @param type Socket type (#PI_SOCK_STREAM or #PI_SOCK_RAW)
  175. * @param protocol Protocol to use (usually #PI_PF_DLP for #PI_SOCK_STREAM sockets)
  176. * @return Socket ID
  177. */
  178. extern int pi_socket PI_ARGS((int domain, int type, int protocol));
  179. /** @brief Assign a new socket descriptor
  180. *
  181. * Assign a new socket descriptor to the socket. On platforms that
  182. * support it, this function reuses the socket's existing descriptor
  183. * after closing it first. In all cases (whether the sd changed or
  184. * not), you don't have to close the new @a pi_sd you passed.
  185. *
  186. * @param ps Socket structure
  187. * @param pi_sd New socket descriptor
  188. * @return The socket structure's new socket descriptor value or negative on error
  189. */
  190. extern int pi_socket_setsd PI_ARGS((pi_socket_t *ps, int pi_sd));
  191. /** @brief Get socket name
  192. *
  193. * Structure needs to have its @a laddr member initialized and valid
  194. *
  195. * @param pi_sd Socket descriptor
  196. * @param remote_addr Will receive the local name
  197. * @param namelen On input, the size allocated to receive the name. On output, the actual name length
  198. * @return 0 on success, negative on error
  199. */
  200. extern int pi_getsockname
  201. PI_ARGS((int pi_sd, struct sockaddr * remote_addr, size_t *namelen));
  202. /** @brief Get a socket's remote address
  203. *
  204. * @param pi_sd Socket descriptor
  205. * @param remote_addr Will receive the remote address/name
  206. * @param namelen On input, maximum name/address length. On output, actual length
  207. * @return 0 on success, negative on error.
  208. */
  209. extern int pi_getsockpeer
  210. PI_ARGS((int pi_sd, struct sockaddr * remote_addr, size_t *namelen));
  211. /** @brief Get a socket option
  212. *
  213. * You can get socket options for various levels of the protocol
  214. * stack. See the options list in #socket.h
  215. *
  216. * @param pi_sd Socket descriptor
  217. * @param level Protocol level (see #PiOptLevels enum)
  218. * @param option_name Option "name" (i.e. #PI_DEV_TIMEOUT at #PI_LEVEL_DEV level)
  219. * @param option_value Pointer to the option value
  220. * @param option_len Len of the pointed option_value.
  221. * @return Negative code on error
  222. */
  223. extern int pi_getsockopt
  224. PI_ARGS((int pi_sd, int level, int option_name,
  225. void *option_value, size_t *option_len));
  226. /** @brief Set a socket option
  227. *
  228. * You can set socket options for various levels of the protocol
  229. * stack. See the options list in #socket.h
  230. *
  231. * @param pi_sd Socket descriptor
  232. * @param level Protocol level (see #PiOptLevels enum)
  233. * @param option_name Option "name" (i.e. #PI_DEV_TIMEOUT at #PI_LEVEL_DEV level)
  234. * @param option_value Pointer to the option value
  235. * @param option_len Len of the pointed option_value.
  236. * @return Negative code on error
  237. */
  238. extern int pi_setsockopt
  239. PI_ARGS((int pi_sd, int level, int option_name,
  240. const void *option_value, size_t *option_len));
  241. /** @brief Retrieve the protocol structure for the given level
  242. *
  243. * You should rarely need to use this function. It allows retrieving
  244. * the protocol structure for any protocol in a socket's protocol
  245. * stack
  246. *
  247. * @param pi_sd Socket descriptor
  248. * @param level Protocol level (see #PiOptLevels enum)
  249. * @return Protocol structure pointer or NULL if not found
  250. */
  251. extern struct pi_protocol *pi_protocol
  252. PI_ARGS((int pi_sd, int level));
  253. /** @brief Browse the protocol stack
  254. *
  255. * You should rarely need to use this function. It allows retrieving
  256. * the next protocol in the stack, up from lower levels to upper
  257. * levels. A protocol stack always has a PI_LEVEL_DEV at bottom, so
  258. * you can use pi_protocol() to retrieve the lowest stack level,
  259. * then repeatedly call pi_protocol_next() to get the next protocol
  260. * in the chain
  261. *
  262. * @param pi_sd Socket descriptor
  263. * @param level Level from which you want to get the next protocol (see #PiOptLevels enum)
  264. * @return Protocol structure ptr, or NULL if not found
  265. */
  266. extern struct pi_protocol *pi_protocol_next
  267. PI_ARGS((int pi_sd, int level));
  268. /*@}*/
  269. /** @name Connection management */
  270. /*@{*/
  271. /** @brief Checks whether a connection is established
  272. *
  273. * If the socket wasn't found, returns 0 and @a errno is set to
  274. * ESRCH.
  275. *
  276. * @param pi_sd Socket descriptor
  277. * @return != 0 if a connection is established
  278. */
  279. extern int pi_socket_connected
  280. PI_ARGS((int pi_sd));
  281. /** @brief Connect to a remote server
  282. *
  283. * Connect to a remote server.
  284. *
  285. * @param pi_sd Socket descriptor
  286. * @param port Port string (see pi_bind() description)
  287. * @return Negative on error
  288. */
  289. extern PI_ERR pi_connect
  290. PI_ARGS((int pi_sd, const char *port));
  291. /** @brief Bind the socket to a specific port
  292. *
  293. * Call this function after creating a new socket with pi_socket()
  294. * to bind the socket to a specific port. Recognized port prefixes
  295. * are: "serial:", "usb:" and "net:". On Unix platforms, you need to
  296. * indicate the /dev entry to bind serial: and usb: to.
  297. *
  298. * @param pi_sd Socket descriptor
  299. * @param port Port string as described above
  300. * @return Negative error code on error
  301. */
  302. extern PI_ERR pi_bind
  303. PI_ARGS((int pi_sd, const char *port));
  304. extern PI_ERR pi_listen PI_ARGS((int pi_sd, int backlog));
  305. /** @brief Wait for a handheld
  306. *
  307. * This function calls pi_accept_to() with a timeout of 0 (wait
  308. * forever). If an error occurs, the socket is closed.
  309. *
  310. * @param pi_sd Socket descriptor
  311. * @param remote_addr Unused. Pass NULL.
  312. * @param namelen Unused. Pass NULL.
  313. * @return Negative error code on error, returns 0 once a device connects
  314. */
  315. extern PI_ERR pi_accept
  316. PI_ARGS((int pi_sd, struct sockaddr * remote_addr,
  317. size_t *namelen));
  318. /** @brief Wait for a handheld
  319. *
  320. * Wait for a device to connect on the port the socket has been
  321. * bound to (using pi_bind()). If an error or timeout occurs, the
  322. * socket is closed.
  323. *
  324. * @param pi_sd Socket descriptor
  325. * @param remote_addr Unused. Pass NULL.
  326. * @param namelen Unused. Pass NULL.
  327. * @param timeout Number of seconds to wait. Pass 0 to wait forever.
  328. * @return Negative error code on error, returns 0 once a device connects
  329. */
  330. extern PI_ERR pi_accept_to
  331. PI_ARGS((int pi_sd, struct sockaddr * remote_addr, size_t *namelen,
  332. int timeout));
  333. /** @brief Close a socket
  334. *
  335. * This function closes a socket and disposes of all the internal
  336. * structures. If a device is currently connected to this socket,
  337. * the connection is interrupted.
  338. *
  339. * @param pi_sd Socket descriptor
  340. * @return Negative error code on error
  341. */
  342. extern int pi_close PI_ARGS((int pi_sd));
  343. /*@}*/
  344. /** @name Low-level data transfers */
  345. /*@{*/
  346. /** @brief Send data on the given socket
  347. *
  348. * Perform a synchronous write on the given socket. Writes are
  349. * performed through the protocol stack. Therefore, the data you
  350. * send will be properly encapsulated in a packet conforming to the
  351. * connected protocol (i.e. NET protocol if you're talking to a
  352. * network or USB device). Usually, you won't send data directly,
  353. * but rather use the dlp_XXX functions to talk to the device.
  354. *
  355. * @param pi_sd Socket descriptor
  356. * @param msg Ptr to the data to send
  357. * @param len Size of the data to send
  358. * @param flags No write flag defined at this time
  359. * @return Number of bytes sent. Negative on error.
  360. */
  361. extern int pi_send
  362. PI_ARGS((int pi_sd, PI_CONST void *msg, size_t len, int flags));
  363. /** @brief Wait for incoming data from the device
  364. *
  365. * Wait for data sent by the device. Note that this function goes
  366. * through the protocol stack, therefore it waits for well-formed
  367. * packets and decodes them to extract the data. Usually, you won't
  368. * use this function directly. Instead, you'll use the dlp_XXX
  369. * functions to talk to the device. Remember that you need to pass a
  370. * valid pi_buffer_t (for example one allocated with
  371. * pi_buffer_new()).
  372. *
  373. * @param pi_sd Socket descriptor
  374. * @param msg Ptr to a valid pi_buffer_t buffer that will contain the received data
  375. * @param len Size of the data we want to read
  376. * @param flags Read flags. Use #PI_MSG_PEEK to leave data in the input buffer.
  377. * @return Number of bytes read. Negative on error.
  378. */
  379. extern ssize_t pi_recv
  380. PI_ARGS((int pi_sd, pi_buffer_t *msg, size_t len, int flags));
  381. /** @brief Wait for incoming data from the device
  382. *
  383. * Alias for the pi_recv() function.
  384. *
  385. * @param pi_sd Socket descriptor
  386. * @param msg Ptr to a valid pi_buffer_t buffer that will contain the received data
  387. * @param len Size of the data we want to read
  388. * @return Number of bytes read. Negative on error.
  389. */
  390. extern ssize_t pi_read PI_ARGS((int pi_sd, pi_buffer_t *msg, size_t len));
  391. /** @brief Write data on the given socket
  392. *
  393. * Alias for the pi_send() function.
  394. *
  395. * @param pi_sd Socket descriptor
  396. * @param databuf Ptr to the data to send
  397. * @param datasize Size of the data to send
  398. * @return Number of bytes sent. Negative on error.
  399. */
  400. extern ssize_t pi_write PI_ARGS((int pi_sd, PI_CONST void *databuf, size_t datasize));
  401. /** @brief Flush input and/or output bytes
  402. *
  403. * Flush incoming and/or outgoing data. Most device implementations
  404. * currently only support flushing the bytes in the incoming data
  405. * buffer, as most writes are synchronous.
  406. *
  407. * @param pi_sd Socket descriptor
  408. * @param flags Mask with valus #PI_FLUSH_INPUT, #PI_FLUSH_OUTPUT.
  409. * @return Negative on error
  410. */
  411. extern void pi_flush PI_ARGS((int pi_sd, int flags));
  412. /*@}*/
  413. /** @name Error codes management */
  414. /*@{*/
  415. /** @brief Return the last error after a low-level or DLP call
  416. *
  417. * If the socket wasn't found, @a errno is set to ESRCH and the
  418. * function returns #PI_ERR_SOCK_INVALID.
  419. *
  420. * @param pi_sd Socket descriptor
  421. * @return Error code or 0 if no error or #PI_ERR_SOCK_INVALID is socket was not found
  422. */
  423. extern int pi_error
  424. PI_ARGS((int pi_sd));
  425. /** @brief Set the last error code
  426. *
  427. * If the socket wasn't found, @a errno is set to ESRCH. If the
  428. * error code is #PI_ERR_GENERIC_MEMORY, @a errno is set to ENOMEM.
  429. *
  430. * @param pi_sd Socket descriptor
  431. * @param error_code Error code to set
  432. * @return The error code
  433. */
  434. extern int pi_set_error
  435. PI_ARGS((int pi_sd, int error_code));
  436. /** @brief Get the last Palm OS error code the device returned to us
  437. *
  438. * After a DLP transaction, if you got a #PI_ERR_DLP_PALMOS error,
  439. * you should call this function to obtain the error code returned
  440. * by the device. It may be either a standard Palm OS error code, or
  441. * one of the DLP errors (see #dlpErrors enum) If the socket wasn't
  442. * found, @a errno is set to ESRCH and the function returns
  443. * #PI_ERR_SOCK_INVALID.
  444. *
  445. * @param pi_sd Socket descriptor
  446. * @return The Palm OS error code or #PI_ERR_SOCK_INVALID if socket was not found
  447. */
  448. extern int pi_palmos_error
  449. PI_ARGS((int pi_sd));
  450. /** @brief Set the last Palm OS error code
  451. *
  452. * If the socket wasn't found, @a errno is set to ESRCH.
  453. *
  454. * @param pi_sd Socket descriptor
  455. * @param error_code Error code to set
  456. * @return The error code
  457. */
  458. extern int pi_set_palmos_error
  459. PI_ARGS((int pi_sd, int error_code));
  460. /** @brief Clear both the last error code and the last Palm OS error code
  461. *
  462. * If the socket wasn't found, @a errno is set to ESRCH.
  463. *
  464. * @param sd Socket descriptor
  465. */
  466. extern void pi_reset_errors
  467. PI_ARGS((int sd));
  468. /*@}*/
  469. /** @name Miscellaneous functions */
  470. /*@{*/
  471. /** @brief Return the version of the DLP protocol supported by the device
  472. *
  473. * Once connected to a handheld, you can call this function to
  474. * obtain the version of the DLP protocol it supports. See pi-dlp.h
  475. * for information about the various DLP versions.
  476. *
  477. * @param pi_sd Socket descriptor
  478. * @return DLP version or #PI_ERR_SOCK_INVALID if socket was not found
  479. */
  480. extern PI_ERR pi_version PI_ARGS((int pi_sd));
  481. /** @brief Return the maximum size of a database record that can be transferred
  482. *
  483. * Use this function to obtain the maximum size a database record
  484. * can be when transferring it to the device. On-device records may
  485. * be larger than what is currently supported by the version of the
  486. * DLP protocol that runs on the device. On devices with an
  487. * implementation of DLP < 1.4, you'll get 0xFFFF meaning that you
  488. * can't transfer records larger than 64k.
  489. *
  490. * If the socket wasn't found, returns 0 and errno is set to ESRCH.
  491. *
  492. * @param pi_sd Socket descriptor
  493. * @return Maximum record transfer size
  494. */
  495. extern unsigned long pi_maxrecsize PI_ARGS((int pi_sd));
  496. /** @brief Tickle a stream connection to keep it alive
  497. *
  498. * Call pi_tickle() at regular intervals to keep the connection
  499. * alive. If you're not sending any command to the device, some
  500. * devices will automatically disconnect after some time. Calling
  501. * pi_tickle() does keep the connection opened, which can be
  502. * necessary if you are writing a conduit that performs lengthy
  503. * tasks like retrieving data from the Internet.
  504. *
  505. * @param pi_sd Socket descriptor
  506. * @return An error code if an error occured (see pi-error.h)
  507. */
  508. extern PI_ERR pi_tickle PI_ARGS((int pi_sd));
  509. /** @brief Set a watchdog that will call pi_tickle() at regular intervals
  510. *
  511. * The watchdog uses the unix SIGALRM to fire an alarm at regular
  512. * intervals. If the socket is still connected when the alarm fires,
  513. * pi_tickle() is called to keep the connection alive.
  514. *
  515. * @param pi_sd Socket descriptor
  516. * @param interval Time interval in seconds between alarms
  517. * @return 0, or #PI_ERR_SOCK_INVALID if the socket wasn't found
  518. */
  519. extern int pi_watchdog PI_ARGS((int pi_sd, int interval));
  520. /*@}*/
  521. #ifdef __cplusplus
  522. }
  523. #endif
  524. #endif /* _PILOT_SOCKET_H_ */