Skip to content
Snippets Groups Projects
Commit fe018e9e authored by Wesley W. Terpstra's avatar Wesley W. Terpstra
Browse files

TCP connection established ok.

parent 1b86b03c
No related merge requests found
......@@ -125,12 +125,20 @@ void eb_device_slave(eb_socket_t socketp, eb_transport_t transportp, eb_device_t
/* < 8: protocol violation! */
if (active) goto kill; /* active link not probed! */
widths = buffer[3];
widths = eb_width_refine(widths & socket->widths);
buffer[2] = 0x12; /* V1 probe response */
buffer[3] = socket->widths; /* passive and transport both use socket widths */
if (passive) device->widths = widths; /* This will be the negotiated width */
/* Bytes 4-7 are echoed back */
eb_transports[transport->link_type].send(transport, link, buffer, 8);
/* Kill the link if negotiation is impossible */
if (!eb_width_possible(widths)) goto kill;
return;
}
......
......@@ -123,12 +123,18 @@ socklen_t eb_posix_ip_resolve(const char* prefix, const char* address, int type,
return len;
}
void eb_posix_ip_non_blocking(eb_posix_sock_t sock, unsigned long on) {
void eb_posix_ip_force_non_blocking(eb_posix_sock_t sock, unsigned long on) {
#if defined(__WIN32)
ioctlsocket(sock, FIONBIO, &on);
#elif defined(EB_POSIX_IP_NON_BLOCKING_NOOP)
/* no-op. DONTWAIT is faster */
#else
ioctl(sock, FIONBIO, &on);
#endif
}
void eb_posix_ip_non_blocking(eb_posix_sock_t sock, unsigned long on) {
#if defined(EB_POSIX_IP_NON_BLOCKING_NOOP)
/* no-op. DONTWAIT is faster */
#else
eb_posix_ip_force_non_blocking(sock, on);
#endif
}
......@@ -51,17 +51,16 @@ typedef SOCKET eb_posix_sock_t;
typedef eb_descriptor_t eb_posix_sock_t;
#if defined(MSG_DONTWAIT) && defined(SOCK_NONBLOCK)
#if defined(MSG_DONTWAIT)
#define EB_POSIX_IP_NON_BLOCKING_NOOP
#else
#ifndef MSG_DONTWAIT
#define MSG_DONTWAIT 0
#endif
#endif
EB_PRIVATE void eb_posix_ip_close(eb_posix_sock_t sock);
EB_PRIVATE eb_posix_sock_t eb_posix_ip_open(int type, const char* port);
EB_PRIVATE socklen_t eb_posix_ip_resolve(const char* prefix, const char* address, int type, struct sockaddr_storage* out);
EB_PRIVATE void eb_posix_ip_non_blocking(eb_posix_sock_t sock, unsigned long on);
EB_PRIVATE void eb_posix_ip_force_non_blocking(eb_posix_sock_t sock, unsigned long on);
#endif
......@@ -46,7 +46,7 @@ eb_status_t eb_posix_tcp_open(struct eb_transport* transportp, const char* port)
return EB_ADDRESS;
}
eb_posix_ip_non_blocking(sock, 1);
eb_posix_ip_force_non_blocking(sock, 1);
transport = (struct eb_posix_tcp_transport*)transportp;
transport->port = sock;
......@@ -160,12 +160,7 @@ int eb_posix_tcp_accept(struct eb_transport* transportp, struct eb_link* result_
transport = (struct eb_posix_tcp_transport*)transportp;
#ifdef EB_POSIX_IP_NON_BLOCKING_NOOP
sock = accept4(transport->port, 0, 0, SOCK_NONBLOCK);
#else
sock = accept(transport->port, 0, 0);
#endif
if (sock == -1) {
if (errno != EAGAIN) return -1;
return 0;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment