pdu_size = rpc_get_pdu_size(rpc->inbuf);
if (rpc->insize < pdu_size) {
unsigned char *buf;
-
+
buf = malloc(pdu_size);
if (buf == NULL) {
rpc_set_error(rpc, "Failed to allocate buffer of %d bytes for pdu, errno:%d. Closing socket.", pdu_size, errno);
if (connect(rpc->fd, (struct sockaddr *)s, socksize) != 0 && errno != EINPROGRESS) {
rpc_set_error(rpc, "connect() to server failed. %s(%d)", strerror(errno), errno);
return -1;
- }
+ }
return 0;
-}
+}
int rpc_connect_async(struct rpc_context *rpc, const char *server, int port, rpc_cb cb, void *private_data)
{
}
return 0;
-}
+}
int rpc_disconnect(struct rpc_context *rpc, char *error)
{
sprintf(service, "%d", port);
if (getaddrinfo(addr, service, NULL, &ai) != 0) {
rpc_set_error(rpc, "Invalid address:%s. "
- "Can not resolv into IPv4/v6 structure.");
+ "Can not resolv into IPv4/v6 structure.", addr);
return -1;
}
case AF_INET:
rpc->fd = socket(ai->ai_family, SOCK_DGRAM, 0);
if (rpc->fd == -1) {
- rpc_set_error(rpc, "Failed to create UDP socket: %s", strerror(errno));
+ rpc_set_error(rpc, "Failed to create UDP socket: %s", strerror(errno));
freeaddrinfo(ai);
return -1;
}
if (bind(rpc->fd, (struct sockaddr *)ai->ai_addr, sizeof(struct sockaddr_in)) != 0) {
- rpc_set_error(rpc, "Failed to bind to UDP socket: %s",strerror(errno));
+ rpc_set_error(rpc, "Failed to bind to UDP socket: %s",strerror(errno));
freeaddrinfo(ai);
return -1;
}
sprintf(service, "%d", port);
if (getaddrinfo(addr, service, NULL, &ai) != 0) {
rpc_set_error(rpc, "Invalid address:%s. "
- "Can not resolv into IPv4/v6 structure.");
+ "Can not resolv into IPv4/v6 structure.", addr);
return -1;
}