File tree 1 file changed +17
-12
lines changed
1 file changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -121,20 +121,25 @@ void UDP::write(const uint8_t *buffer, size_t size)
121
121
122
122
int UDP::parsePacket ()
123
123
{
124
- // HACK - hand-parse the UDP packet using TCP recv method
125
- uint8_t tmpBuf[8 ];
126
- int ret =0 ;
127
- // read 8 header bytes and get IP and port from it
128
- ret = recv (_sock,tmpBuf,8 );
129
- if (ret > 0 )
124
+ if (available () > 0 )
130
125
{
131
- _remoteIP = tmpBuf;
132
- _remotePort = tmpBuf[4 ];
133
- _remotePort = (_remotePort << 8 ) + tmpBuf[5 ];
134
- // When we get here, any remaining bytes are the data
135
- ret = available ();
126
+ // HACK - hand-parse the UDP packet using TCP recv method
127
+ uint8_t tmpBuf[8 ];
128
+ int ret =0 ;
129
+ // read 8 header bytes and get IP and port from it
130
+ ret = recv (_sock,tmpBuf,8 );
131
+ if (ret > 0 )
132
+ {
133
+ _remoteIP = tmpBuf;
134
+ _remotePort = tmpBuf[4 ];
135
+ _remotePort = (_remotePort << 8 ) + tmpBuf[5 ];
136
+ // When we get here, any remaining bytes are the data
137
+ ret = available ();
138
+ }
139
+ return ret;
136
140
}
137
- return ret;
141
+ // There aren't any packets available
142
+ return 0 ;
138
143
}
139
144
140
145
int UDP::read ()
You can’t perform that action at this time.
0 commit comments