Fix udp again
This commit is contained in:
parent
e346230c60
commit
a4c3018c79
1 changed files with 8 additions and 2 deletions
10
src/packet.c
10
src/packet.c
|
@ -48,6 +48,12 @@ enum FD_STATE write_packet_to_udp(int fd, struct buffer_packet* bp, struct udp_t
|
||||||
ssize_t nwrite;
|
ssize_t nwrite;
|
||||||
size_t bytes_to_send;
|
size_t bytes_to_send;
|
||||||
size_t pkt_header_size = sizeof(bp->ip.ap.str) - sizeof(char);
|
size_t pkt_header_size = sizeof(bp->ip.ap.str) - sizeof(char);
|
||||||
|
struct sockaddr* addr = NULL;
|
||||||
|
socklen_t addrlen = 0;
|
||||||
|
if (udp_t->set) {
|
||||||
|
addr = (struct sockaddr*) &udp_t->addr;
|
||||||
|
addrlen = sizeof(struct sockaddr_in);
|
||||||
|
}
|
||||||
|
|
||||||
if (bp->mode != BP_WRITING) return FDS_ERR;
|
if (bp->mode != BP_WRITING) return FDS_ERR;
|
||||||
|
|
||||||
|
@ -56,8 +62,8 @@ enum FD_STATE write_packet_to_udp(int fd, struct buffer_packet* bp, struct udp_t
|
||||||
&(bp->ip.ap.str.payload),
|
&(bp->ip.ap.str.payload),
|
||||||
bytes_to_send,
|
bytes_to_send,
|
||||||
0,
|
0,
|
||||||
(struct sockaddr*)&udp_t->addr,
|
addr,
|
||||||
udp_t->addrlen);
|
addrlen);
|
||||||
|
|
||||||
if (nwrite == -1 && errno == EAGAIN) return FDS_AGAIN;
|
if (nwrite == -1 && errno == EAGAIN) return FDS_AGAIN;
|
||||||
if (nwrite != bytes_to_send) return FDS_ERR;
|
if (nwrite != bytes_to_send) return FDS_ERR;
|
||||||
|
|
Loading…
Reference in a new issue