Send #define line with packets from server to client - packets

I have a game server. He communicates with the client via packet. I want to send line
#define From the server to the client with a packet.
In this way not I be forced to recompile the source to the client always.
Basically I can activate functions that are source directly from server to client.
I just need an example about this. :D Please help.
typedef struct define_packet_send {
BYTE header;
int define_max_len[20];
long data;
}
But how to send the define in a specific file. I hope you guys you understand what i mean.

Related

Read UDP packet stream into SQL Server

I have a device that broadcasts a UDP ASCII stream on my network and I want to receive and parse that stream into my db.
Do I need to buy or build UDP receiver middleware to do the protocol conversion or can this be done inside of SQL Server 2017 without third-party tools?
If you have someone with some coding knowledge, you could implement your UDP receiver in powershell see this question for example
and then send whatever data you received to your database. see here for example
In any case I would rather put that outside of the DB itself.
But if you feel like it must be within the DB, maybe it's possible to do it with stored procedure.

Arduino read from port 1, send to port 0

I got this snippet of code from the Blueduino board manufacturer's page. It works fantastically for two-way communication, it seemed simple but after much searching I can't understand what it is doing.
This is the code:
// read from port 1, send to port 0:
if (Serial1.available()) {
int inByte = Serial1.read();
Serial.write(inByte);
}
// read from port 0, send to port 1:
if (Serial.available()) {
int inByte = Serial.read();
Serial1.write(inByte);
}
It's obvious it's writing the in to the out and vice-versa (Rx to Tx I believe) but I am not sure why.
This code is working and when I write in the serial monitor it is received on the phone, but I'm not sure how this code is taking the message I send in the serial monitor and inserting it in the stream.
Thanks in advance for your help.
This code is forwarding messages from one serial device to another.
Most likely between your Arduinos serial interface (to your pc) to the blueduino board.
You cannot connect your PC to the Phone directly and you cannot wire the blueduino-board directly to the serial lines of your PC.
Hence you need something in between. (your arduino) that forwards every single byte.
The code you have basically does the same for both ports. If a byte is in the serial receive buffer, read it and send it to the other port.

sending both files and strings via tcp in vb.net

Apologies if my terminology is not correct with this question, but bear with me.
I know what I want to achieve, just not sure what the proper names are for the classes/functions etc.
I need to make a client/server application using tcplistener and tcpclient which will allow me to send both strings and files... I think.
So in layman's terms, I want to make a server application that will listen for connections from a client on a specific port. The clients will essentially connect to the server and say "hey, I'm client 172.16.10.12. I'm going to send you a file called test.txt, which is 2330k in size. The file's MD5 hash is xxxxxxxxxxx".
Once that communication has taken place, I want the client to then send the file 'test.txt' to the server; the server saving the file to an appropriate location before then generating the file's MD5 hash and comparing it to the MD5 and file size the client proposed, before finally reporting back to the client 'Ok' or 'Success'.
If the file size or MD5 differ, it will be 'Fail'.
I'm not asking for anyone to do this for me, but for someone to nudge me in the right direction. All of the tutorials/examples I seem to find on here or youtube etc seem to focus on either files or strings. I cant seem to find one which would cater for both, which is what I think i may need, although I may be wrong.
I hope that all makes sense! Huge thanks in advance for any help on this.
This is the first time i've played with TCP functions, having always used FTP before because of perceived ease.
I believe for this small file you can convert a file to bytes on client side and then send it over tcp as byte array and the server application will rebuild the file from the byte array with File.WriteAllbytes.
Save byte array to file
Here is how to get bytes from file. PS I am not very experienced just posting something.. Reliable way to convert a file to a byte[]
This should work out of box for sending byte array as tcp I never tried what I wrote but it have to work.
try
{
string Hostname = "127.0.0.1";
TcpClient Client = new TcpClient(Hostname, 10000);
byte[] packet = new byte[] { 0x17, 0x03, 0x01, 0x4c };
Client.Client.Send(packet);
}
catch (SocketException e)
{
}

Set the time to live (TTL) of IP packets for outgoing UDP datagrams on Arduino Ethernet

I'm using an Arduino Ethernet to send UDP datagrams to a remote host. The code I use to send a single datagram is:
Udp.begin(localPort);
...
Udp.beginPacket(remoteIP, remotePort);
Udp.write(data);
Udp.endPacket();
My issue is that I need to customize the TTL of the outgoing UDP/IP packet, but none of Udp.begin, Udp.beginPacket, Udp.write and Udp.endPacket provide a parameter to set such option.
I know that the TTL field belongs to the IP header but it seems you don't handle raw IP packets using Arduino's Ethernet / socket / w5100 libraries.
I looked into the definitions of the above functions, expecially in EthernetUDP::beginPacket where I was wondering to find something useful being it called just before I pass the payload of the message, but I got stuck since it contains not much more than a call to startUDP() (socket.cpp), and the latter deals with methods of the W5100 class that are not clear to me.
Do someone know if there is a somehow high-level facility to set the TTL of a packet, or should one go deeper into the libraries to achieve that?
Finally I found a solution. The WIZnet W5100 socket provide registers that describe the socket's behaviour as documented in W5100 Datasheet Version 1.1.6. One of these registers is Socket 0 IP TTL (S0_TTL) (address 0x0416). I see that those registers are written in the startUDP function (in socket.cpp) in order to set the socket's destination IP address and port:
W5100.writeSnDIPR(s, addr);
W5100.writeSnDPORT(s, port);
so I appended there a call to
W5100.writeSnTTL(s, (uint8_t) 255); // set TTL to 255
and it indeed worked, i.e. the sketch got compiled. Such method is undocumented, I figured it out looking at the other register-writing methods and finding on the web that exists a couple of projects that make use of it.
I also wrote this patch to provide the override Udp.beginPacket(remoteIP, remotePort, ttl) to the Ethernet libraries that come with Arduino 1.0.1 - 2012.05.21.

Lua custom UDP Header

Is there a way to create a custom UDP header in Lua? I am using Ubuntu 11.10, Lua 5.1, and Luasocket. Am I missing a module for this to work or is it impossible?
What I was planning to do is to send a character in the length section of the UDP header from the client then decode it on the server. Is there a better way of doing this without sending data via normal data transfer?
Thanks.
The only way to modify packet headers is to use raw sockets and construct the packet yourself, including both the IP and UDP headers.
However, what you want to do, use the length field for data, will not work. Remember that all routers/switches/hubs between your client and server looks at the header to determine how long the packet is. If there isn't a valid length there they will fail sending your packet on.