I want to make a programm that works like an instant messenger and I´m already finished but I don´t know how to send/receive strings to a specific IP adress.
I included myself a Method where this stuff belongs to:
//is called every second and when you commit a message
public void Update(ref eStatus prgmStatus, ref eProfile userProfile)
{
UpdateUI(ref prgmStatus);
[ Some other Update Methods ]
[ Catch the string and add it to userProfile.CurrentChatHistory]
}
public void EnterText(object sender, EventArgs e)
{
_usrProfile.CurrentChatHistory.Add(chatBox.Text);
[ send chatBox.Text to IP 192.168.0.10 (e.g.) ]
}
I want to use a client to client System without any extra server software running.
What system namespaces and methods can I use to achieve this?
The System.Net namespace is where you will need to look.
If you are doing a peer-to-peer chat where you may need to send messages to multiple IP addresses, with no central server, it may be best to use UDP.
Having seen from your comment that you have no central server, I’d suggest you use UDP, at least initially, for a quick start up. The UdpClient class is your friend here, allows you to send packets to any specified network address.
You can basically just create a new UdpClient instance, passing a known port number to bind to into the constructor.
Then, use the Receive method to read a packet on that port.
You can also then use the Send method on the same instance to send a packet to a network address.