/**
 * See pcsl_socket.h for definition.
 */
int pcsl_socket_open_finish(
    void *handle,
    void *context)
{
    int err;
    socklen_t err_size = sizeof(err);

    int fd = na_get_fd(handle);

    int status = getsockopt(fd, SOL_SOCKET, SO_ERROR, &err, &err_size);
    /*
     * DEBUG:
     * printf( "pcsl_socket_open_finish::handle=%d err=%d\n", fd, err);
     */

    lastError = err;

    if (err == 0) {
        na_unregister_for_write(handle);
        /*
         * DEBUG:
         * printf("opened fd: %d\n", fd);
         */
        return PCSL_NET_SUCCESS;
    } else {
        na_destroy(handle);
        close(fd);
        return PCSL_NET_IOERROR;
    }
}
示例#2
0
/**
 * See pcsl_network.h for definition.
 */
void pcsl_remove_network_notifier(
    void *handle,
    int event) {
    switch (event) {
    case PCSL_NET_CHECK_READ:
    case PCSL_NET_CHECK_ACCEPT:
        na_unregister_for_read(handle);
        break;
    case PCSL_NET_CHECK_WRITE:
        na_unregister_for_write(handle);
        break;
    case PCSL_NET_CHECK_EXCEPTION:
        /* need revisit */
        break;
    }
}
/**
 * See pcsl_socket.h for definition.
 */
int pcsl_socket_write_finish(
    void *handle,
    char *pData,
    int len,
    int *pBytesWritten,
    void *context)
{
    int status;

    status = pcsl_socket_write_common(handle, pData, len, pBytesWritten);

    if (status == PCSL_NET_WOULDBLOCK) {
        na_register_for_write(handle);
    } else {
        na_unregister_for_write(handle);
    }
    return status;
}
示例#4
0
/**
 * See pcsl_datagram.h for definition.
 */
int pcsl_datagram_write_finish(
	void *handle,
    unsigned char *ipBytes,
	int port,
    char *buffer,
    int length,
	int *pBytesWritten,
	void *context)
{
    int status;

    status = pcsl_datagram_write_common(handle, ipBytes, port, buffer, 
                length, pBytesWritten);
    
    if (status == PCSL_NET_WOULDBLOCK) {
        na_register_for_write(handle);
    } else {        
        na_unregister_for_write(handle);
    }
    return status;
}