Link to home
Start Free TrialLog in
Avatar of uvals
uvals

asked on

Python's UDP Socket & Struct Pack equivalent code needed in C#

Need equivalent C# code for the below Python code
#!/usr/bin/python
import socket
import struct
import sys
import time
 
s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
 
s.sendto(struct.pack("8B",255,16,176,0,0,0,0,0),("192.168.1.3",8080))

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of jimbobmcgee
jimbobmcgee
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Looking into it a bit further, are you just trying to send 8 bytes of data?  If so, replace the Encoding.ASCII.GetBytes call with your own byte[].
byte[] message = new byte[] { 255, 16, 176, 0, 0, 0, 0, 0 };

Open in new window