# Send UDP packet to dest + specific Local port?

**URL:** <https://forum.sierrawireless.com/t/send-udp-packet-to-dest-specific-local-port/5074>\
**Category:** Open AT\
**Created:** [May 22, 2011, 8:50pm UTC](https://forum.sierrawireless.com/t/send-udp-packet-to-dest-specific-local-port/5074 "2011-05-22T20:50:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonpio](https://avatars.discourse-cdn.com/v4/letter/j/6a8cbe/32.png) [@jonpio](https://forum.sierrawireless.com/u/jonpio)\
**Post date:** [May 22, 2011, 8:50pm UTC](https://forum.sierrawireless.com/t/send-udp-packet-to-dest-specific-local-port/5074/1 "2011-05-22T20:50:51Z")

</div>

I need to send a UDP packet to specified IP & port with Specified local/source port.

How do I do it ? this is what I want to work

```auto
sockets[0].socket = wip_UDPCreateOpts( evh_udp, &sockets[0],
						  WIP_COPT_PEER_STRADDR,	Globals.servername,
						  WIP_COPT_PEER_PORT, PEER_PORT,
						  WIP_COPT_PORT, LOCAL_PORT,
						  WIP_COPT_END);

case WIP_CEV_WRITE: // socket is writable

		wip_getOpts(ev->channel,
					  WIP_COPT_PEER_ADDR,	&sockets[0].PeerIPaddr,
					  WIP_COPT_BOUND, &sockets[0].isbound,
					  WIP_COPT_END

			  	  	  );

error = wip_writeOpts( sockets[0].socket, "hello",5,
								WIP_COPT_PEER_ADDR,	sockets[0].PeerIPaddr,
								WIP_COPT_PEER_PORT,	PEER_PORT,
								WIP_COPT_PORT, LOCAL_PORT,
								WIP_COPT_END);
```

However, after trying all permutations of UDP server sockets & client sockets, all I can say is that Server sockets only send from a “Bound” incoming port, ie you cannot send until received. & client sockets do not accept wip\_writeOpts() - I’m trying to do a bit of both.

I am wrestling with this wip lib 👿 there is no consistent “philosophy” to it, everything works as per the examples/docs but deviate even slightly & it does not work. for example using the same code for multiple bound/unbound UDP sockets + TCP sockets.

wip\_readOpts() nor wip\_GetOpts() work on TCP client sockets  
&  
wip\_read() does not work on UDP sockets

You cannot use wip\_writeOpts() with a Server socket, despite secifying every thing, cause the “channel not ready” ie it wants the channel from an incoming packet/connection (does not exist yet)

---

<div class="post-metadata">

**Author:** ![paruthiv](https://avatars.discourse-cdn.com/v4/letter/p/eb8c5e/32.png) [@paruthiv](https://forum.sierrawireless.com/u/paruthiv)\
**Post date:** [June 2, 2011, 5:09am UTC](https://forum.sierrawireless.com/t/send-udp-packet-to-dest-specific-local-port/5074/2 "2011-06-02T05:09:51Z")

</div>

Hi

> [@](#):
>
> wip\_readOpts() nor wip\_GetOpts() work on TCP client sockets & wip\_read() does not work on UDP sockets

What exactly you mean by that? Have you checked out the return value you get in these cases?

---

<div class="post-metadata">

**Author:** ![jonpio](https://avatars.discourse-cdn.com/v4/letter/j/6a8cbe/32.png) [@jonpio](https://forum.sierrawireless.com/u/jonpio)\
**Post date:** [July 7, 2011, 12:48pm UTC](https://forum.sierrawireless.com/t/send-udp-packet-to-dest-specific-local-port/5074/3 "2011-07-07T12:48:45Z")

</div>

Anyone got more info on my question ?? How do you send a UDP packet with everything specced ? I am attempting to pierce firewalls.

> [@paruthiv](#):
>
> What exactly you mean by that? Have you checked out the return value you get in these cases?

Various return values like Invalid function, or invalid param (terms as I remember them). I realise that the documentation lists which functions work with which context, however they do not say which are incompatible. So in philosophical terms why should wip\_readOpts() fail when used with a client socket ?? even if unnecessary ??

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [July 7, 2011, 12:55pm UTC](https://forum.sierrawireless.com/t/send-udp-packet-to-dest-specific-local-port/5074/4 "2011-07-07T12:55:18Z")

</div>

> [@jonpio](#):
>
> I am attempting to pierce firewalls

Note that firewalls can be configured to simply block all UDP traffic…

---

<div class="post-metadata">

**Author:** ![jonpio](https://avatars.discourse-cdn.com/v4/letter/j/6a8cbe/32.png) [@jonpio](https://forum.sierrawireless.com/u/jonpio)\
**Post date:** [July 7, 2011, 1:27pm UTC](https://forum.sierrawireless.com/t/send-udp-packet-to-dest-specific-local-port/5074/5 "2011-07-07T13:27:22Z")

</div>

> [@awneil](#):
>
> Note that firewalls can be configured to simply block all UDP traffic…

And this is helpful information ??, firewalls can also be setup to block port 80 😆

Anyone on topic ?

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [July 7, 2011, 1:50pm UTC](https://forum.sierrawireless.com/t/send-udp-packet-to-dest-specific-local-port/5074/6 "2011-07-07T13:50:48Z")

</div>

> [@jonpio](#):
>
> And this is helpful information ??

The point being, if the firewall is set to just block all UDP packets, then no amount of fiddling with your UDP sending options is going to get around that!

---

<div class="post-metadata">

**Author:** ![jonpio](https://avatars.discourse-cdn.com/v4/letter/j/6a8cbe/32.png) [@jonpio](https://forum.sierrawireless.com/u/jonpio)\
**Post date:** [July 11, 2011, 7:58pm UTC](https://forum.sierrawireless.com/t/send-udp-packet-to-dest-specific-local-port/5074/7 "2011-07-11T19:58:32Z")

</div>

back to the topic please 🙂
