Betascript Publishing CRiSP File Editor 6 Instrukcja Użytkownika Strona 83

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 92
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 82
Page 83
/* We have either successfully or unsuccessfully */
/* connected to the remote host. */
/* We can tell the difference by whether the ipc_write */
/* is successful or not. */
if (ipc_write(ipc_id, "Hello\n") < 0) {
message("Writing data failed.");
}
/* If we keep the connection open at this point, make */
/* sure to unregister the IPC_TRIGGER_WRITE trigger */
/* otherwise it will keep firing. */
/* In this example, we simply close the connection when */
/* we are done. */
ipc_close(ipc_id);
}
The following example illustrates creating a service which other applications can connect to.
void
server_example()
{ int ipc_id;
if ((ipc_id = ipc_create(IPC_TCP, "1234")) < 0) {
message("Failed to create server port");
return;
}
/* Register macro to handle new incoming connections. */
/* Note: we pass in the ipc_id as an argument so the */
/* callback knows which connection to use. */
ipc_register(ipc_id, IPC_TRIGGER_READ,
"new_connection " + ipc_id);
}
void
new_connection(int ipc_id)
{ int ipc_id2;
stringstr;
if ((ipc_id2 = ipc_accept(ipc_id)) < 0) {
message("Failed to handle new connection request.");
return;
}
/* Read message request from the remote client */
str = ipc_read(ipc_id2);
message("Received '%s'", str);
/* Close down the connection */
ipc_close(ipc_id2);
}
{button See Also, ALink(ipc,,,)}
Przeglądanie stron 82
1 2 ... 78 79 80 81 82 83 84 85 86 87 88 ... 91 92

Komentarze do niniejszej Instrukcji

Brak uwag