To get it clear:
you have a server PC and 30 modems connected to it on RS232
you want to send data from another PC to the modem(s)
If so, you need to write 2 applications. A server app that receives data from the other PC and sends the data to a specified modem and a client app that sends the data to the server PC.
Before you can start coding,
1)
You need to define a protocol (command set and replies) for the communication between the client and the server. Below some simple examples
Code:
command: txt modemnumber textstring
reply : txt modemnumber status
command: file modemnumber length databytes
reply : file modemnumber status
What should happen:
When the server receives the complete txt command, it will send the textstring to the specified modem. After this, the server will reply to the client with a status, e.g
>=0 for OK (the number indicates the number of bytes send to the modem)
-1 unknown command
-2 incorrect command format
-3 no reply from modem
-4 other error
It's up to you if the protocol is binary based (where commands and modemnumber are integers) or ascii based (where the command and modemnumber are transmitted as text). The underlaying code will be the same (a byte is a byte, regardless if it's a ascii character or an e.g 8-bit integer).
Ascii is slightly easier to start with as you can start of with telnet on the client PC and concentrate on the server side.
Please note that the given examples are simple. You can add error checking (e.g a CRC of the message) as well or break files into pieces.
2)
You also have to decide if you're going to use UDP or TCP; it depends on your application which one you can use. TCP guarantees that packets are received by the receiver (or you will receive an error message). If you use UDP, you might have to implement some additional checks if you want to make sure that packets have arrived.
With the UDP you can not use telnet for testing.