If you are using UDP to send and receive the data you would bind it but you wouldn't need to connect it to the server because UDP is a connectionless protocol if you are using TCP to transmit the data( which is what you should be using) you wouldn't need to bind your socket to part cause you should be issuing a TCPClient.connect from the client and have the server accept the incoming connect request with first having a TCPListener listening on the specified port, with TCPListener.Start and then using TCPClient = TCPListener.AcceptTCPClient to accept the incoming connection request then setting up a network stream so you can read and write data on the stream
Wonderful tutorial. Just came by to take a look at Visual C# and was so happy to discover that you were sharing of examples of code that I needed to explore. Thank you and wishing you a happy new year.
Hey, this is great! I'm new at VB, also at programming, but found this tutorial very useful. I have some questions like: Shouldn't you also handle any exceptions like when you can't connect to your friend? or Wouldn't you also need a "Disconnect" button?
Hello Mr Ripon good project but i have a question, does it work only on local network or can i use it to chat with my friend who lives in another country?
this is really awesome tutorials....thanks for this one... I just want to ask If I can input the IP manually to running windows form? example this program run in my comp and my friend run also this program in his/her computer in the same local area network. thanks in advance.. more power to you mate...
Awesome tutorial! Can you make a tutorial with this, on how can I change font & color using fontdialog when I click the send. I can change the font & color in textMessage but when I hit the send button it turns back to normal. thanks in advance!
Hello, can I ask a question? I want to Connect to Arduino by Wi-Fi address. I write the Windows Form by C#, but I can't connect to the board. Can you teach me? I am a rookie in C#, Please.
Hi Ripod, great tutorial man !! I have a query regarding using this code for web app. I have tried to use this code in web pages but getting error while sending msg at line socket.Send(sendingMessage); error msg is "A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied" can you please help me out on how can I implement this for web application.
help! System.Net.Sockets.SocketException: A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied
See in // binding Socket in epRemote, if you put sck.Bind (epRemote) or sck.Connect (epRemote), it may have put sck.Bind (epRemote) and it must be sck.Connect (epRemote).
Ripon, I just subscribed, I would like to know the following. Is this specific to LAN networks, must it run over internet connection, and can it be done in a home/office setup? Once again, good work brother, explain to the par. Thank you again, I know what I'll be doing this evening.
hi i have a problem after i have open exe file there is a error like that "input string was not in a correct format" after i continue this message i create chat with other part of chat app after that i recieve that message box "a request to send or recieve data was disallowed because the socket is not connected and (when sending the datagram socket using a sendtro call)no address was supplied" s plz help me in this?
you may wrote txtLocalIp.Text instead of txtLocalPort.Text. Or the port text boxes are empty. epLocal = new IPEndPoint(IPAddress.Parse(textLocalIp.Text),Convert.ToInt32(textLocalPort.Text));
I have a problem, i open 1 port at My Router, I sent to my friend IP Router and this Port. My friend can chat with me by using Socket Chat Application, I also chat with myselft by using this. But 1 program like as Skype or web as facebook not only don't need open a port, but also message is sent. I don't know how I do it? Hope you give me more inforamation usefully, thanks
works on my machine, but cant get it to work with a co worker on the same network. Any Ideas? We configured everything correctly used his ip, and hit connect.. but no messages
Hey, how do i connect to other pc's to chat with and not with myself. As exmaple i want to chat with someone else in other place of my country, how to do, or is this only for local chat?
hii, it says that something wrong and it gives an error if i start the exe and it says that the error is in this part of the code: (sorry my english's bad im dutch 13) System.Net.Sockets.SocketException (0x80004005): Een aanvraag om gegevens te verzenden of te ontvangen is niet toegestaan omdat de socket niet is verbonden en omdat (tijdens het verzenden op een datagramsocket via een sendto-aanroep) geen adres is opgegeven bij System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) bij System.Net.Sockets.Socket.Send(Byte[] buffer) bij chat.Form1.buttonSend_Click(Object sender, EventArgs e) in c:\Users\Gebruiker\Desktop\keylogg\chat\chat\Form1.cs:regel 98 bij System.Windows.Forms.Control.OnClick(EventArgs e) bij System.Windows.Forms.Button.OnClick(EventArgs e) bij System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) bij System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) bij System.Windows.Forms.Control.WndProc(Message& m) bij System.Windows.Forms.ButtonBase.WndProc(Message& m) bij System.Windows.Forms.Button.WndProc(Message& m) bij System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) bij System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) bij System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) this is the original code that i've write: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Net; using System.Net.Sockets; namespace chat { public partial class Form1 : Form { Socket sck; EndPoint epLocal, epRemote; byte[] buffer; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { //set up socket sck = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); sck.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); //get user ip textLocalIP.Text = "192.168.2.10"; textRemoteIP.Text = "192.168.2.10"; } private string GetLocalIP() { IPHostEntry host; host = Dns.GetHostEntry(Dns.GetHostName()); foreach (IPAddress ip in host.AddressList) { if (ip.AddressFamily == AddressFamily.InterNetwork) return ip.ToString(); } return "127.0.0.1"; } private void buttonConnect_Click(object sender, EventArgs e) { //binding socket idk wat socket is epLocal = new IPEndPoint(IPAddress.Parse(textLocalIP.Text), Convert.ToInt32(textLocalPort.Text)); sck.Bind(epLocal); //connecting to remote IP epRemote = new IPEndPoint(IPAddress.Parse(textRemoteIP.Text), Convert.ToInt32(textRemoteIP.Text)); sck.Connect(epRemote); //listening the specific port buffer = new byte[1500]; sck.BeginReceiveFrom(buffer, 0, buffer.Length, SocketFlags.None, ref epRemote, new AsyncCallback(MessageCallBack), buffer); } private void MessageCallBack(IAsyncResult aResult) { try { byte[] receivedData = new byte[1500]; receivedData = (byte[])aResult.AsyncState; //converting byte[] to string ASCIIEncoding aEncoding = new ASCIIEncoding(); string receivedMessage = aEncoding.GetString(receivedData); //adding this message into listbox listMessage.Items.Add("Friend: " + receivedMessage); buffer = new byte[1500]; sck.BeginReceiveFrom(buffer, 0, buffer.Length, SocketFlags.None, ref epRemote, new AsyncCallback(MessageCallBack), buffer); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } private void buttonSend_Click(object sender, EventArgs e) { //convent string message to byte[] ASCIIEncoding aEncoding = new ASCIIEncoding(); byte[] sendingMessage = new byte[1500]; sendingMessage = aEncoding.GetBytes(textMessage.Text); //sending the encoded message sck.Send(sendingMessage); //adding to listbox listMessage.Items.Add("Me: " + textMessage.Text); textMessage.Text = ""; } } } i've also the program virtual box and the program is grab the ip of that program so i write in the textboxes my true ip greets jesse
Jesse Gerritsen Sorry I can't read your language of error message. If you could write it in English version, I would be able to figure out your error. Thank you. Keep in touch.
See in // binding Socket in epRemote, if you put sck.Bind (epRemote) or sck.Connect (epRemote), it may have put sck.Bind (epRemote) and it must be sck.Connect (epRemote).
i am very interested in this application: 1- any possibility to add attachment button ? 2- any possibility to have the code for this application ? Many thanks
hello Mr, I watched your tutorial and applied the same process but I want to add Memory Mapped File to the code. I couldnt do this. Can you help me to solve the problem?
i hve a doubt ........is that.. why u hve taken port no 80 or 81?......n if i wnt to use another port for communication to remote pc ....so i hve to check in command prompt that which port is valid or for communication or there is specific port like that u hve used?n i hve to enter remote pc's ip address & port no also .......for this how can i check remote pc's port no...?
I have copied your code identically into a windows form using visual studio 2012 and I get an exception error on this line of code epLocal = new IPEndPoint(IPAddress.Parse(txtLocalIP.Text), Convert.ToInt32(txtLocalPort.Text)); Input string not in the correct format. Any ideas
Drino Duka follow the tutorial agian. Thank you so much. Write your voice or request in my site www.rdatta.com/You/YourVoice . Keep in touch with my site www.rdatta.com , www.f6build.com , www.di-ioc.com , www.codeffi.com and stay well.
I really like your tutorial, do you know how to add ÅÄÖ characters to work in this chat? i know its something with the Ascii but I dont know how, thanks again!
when i try to connect one error occured in my project FormatException was unhandled, input string is not in correct format in this line epLOcal= new IPEndPoint(IPAddress.Parse(textLocalIp.Text), Convert ToInt32(textLocalPort.Text)); i give prot number 80 and 81 plz help me
Hello Ripon Datta, I have a project Internet Messenger Desktop Application , Please can u make a video from User registration to Chat between client to client over internet and send message from server to clients , Only connected clients get message from server. and Logged in clients chat to each other. I am really very thankful to you.
while ruuning this application sometime its work fine but in WHEN i run 2 exe on same pc and send message from one application to other it shows cross thread operation operation not valid :control listbox_messge accessed from a thread otther than a thread it was created own
Great tutorial man! But there was an error in this code string.receivedData = aEncoding.GetString(receivedData); first receivedData is an error what can i do?
wonderful. but i've got a problem when i click "connect" its shows :impossible d'effectuer un cast d'un objet de type "System.Windows.Forms.TexBox"' en type "System.Iconvertible". Meanwhile i put the same values as you , for the ports. Can you help me please?
+Axel MOUELE In buttonConnect_Click, you have missed to Convert.ToInt32(textRemotePort.Text)) or Convert.ToInt32(textLocalPort.Text)).The ".Text" part specially, I did the same thing and got the same error. Try it out.
why did you callback'ed again at 19:00.. is it for recursively receiving the message from remote user as u have again passed the argument as MessageCallBack in AsynchCallBack().. doesn't it mean to be the recursive function?? :o Help..
Greetings; I'm getting the following Error: "An Invalid Argument Was Supplied" I've watched the entire Tutorial several times and Double Checked Everything. Everything seems correct and i can't figure the problem. According to the kind of Error Message the Problem lies under the "Connect Button" Coding. protected void Button1_Click(object sender, EventArgs e) { //binding socket epLocal = new IPEndPoint(IPAddress.Parse(textLocalIP.Text), Convert.ToInt32(TextBox2.Text)); sck.Bind(epLocal); //connecting to friend IP epRemote = new IPEndPoint(IPAddress.Parse(textFriendIP.Text), Convert.ToInt32(TextBox4.Text)); sck.Bind(epRemote); //listening to specific port buffer = new byte[1500]; sck.BeginReceiveFrom(buffer, 0, buffer.Length, SocketFlags.None, ref epRemote, new AsyncCallback(MessageCallBack), buffer); } Can Anyone Help me out in figuring this out? Thanks in advance.
nice job, and I love it when someone can do a programming tutorial and I hear chickens clucking in the background.
Nevermind. I figured out what was wrong. Thank you. Great video !!!
I'm getting error when I click on connect button ...It shows 'an invalid argument was supplied' exception
DIDU SOLVE IT ?
@Boston Mendonca I tried that actually 2 years ago so don't even remember now
When I try to connect to another PC it says that I have an error connecting to the socket and it doesn’t let me chat please help
Is the other pc listening for connections?
If you are using UDP to send and receive the data you would bind it but you wouldn't need to connect it to the server because UDP is a connectionless protocol if you are using TCP to transmit the data( which is what you should be using) you wouldn't need to bind your socket to part cause you should be issuing a TCPClient.connect from the client and have the server accept the incoming connect request with first having a TCPListener listening on the specified port, with TCPListener.Start and then using TCPClient = TCPListener.AcceptTCPClient to accept the incoming connection request then setting up a network stream so you can read and write data on the stream
DISLIKERS, GET OFF TH-cam NNOOOOOWWW!!!!!! Good job, Ripon Datta.
The worlds best programmer.
Wonderful tutorial. Just came by to take a look at Visual C# and was so happy to discover that you were sharing of examples of code that I needed to explore. Thank you and wishing you a happy new year.
Guys it's working perfectly when you give your port number in 4 digits like 8000 and 8001 ..Maybe a illegal solution but still it worked for me.
Thank you Ripon for thorough explanation!
Hey, this is great! I'm new at VB, also at programming, but found this tutorial very useful. I have some questions like: Shouldn't you also handle any exceptions like when you can't connect to your friend? or Wouldn't you also need a "Disconnect" button?
Wow, I learned more in an hour than in years. Wow!
Thanks for the tutorial :) I've done chat programmes before but only with TCP so it was great to see how to use it UDP :D
can you teach me?
i have 44 errors in the first 11 minutes and im following literally everything you are doing
could you ever get it to work I have been trying to fix one error for over a week. can you summit the correct code?
Thank you. Its working for me.
Worked well for me.... Now for a ,more advanced one. Thank you.
can you summit the correct code?
Is this only for lan connection?
Can I use this with a friend if he provides me the IP to connect him?
I would use log me in hamachi
Hello Mr Ripon good project but i have a question, does it work only on local network or can i use it to chat with my friend who lives in another country?
Thanks Smith, you can use voice synthesizer.
if I am from Ukraine and my friend from Germany, I could not contact him cheres this program ?? They only work program through the local ip
Привет. Я тоже с Украины)) Такая же проблема))
this program works only on your local network. this guy can't make a chat over the internet
Thank you very much for this nice and helpful tutorial!
this is for one common network .what to do if a network is no common?? Is there any link who shows a program for the different network?
this is really awesome tutorials....thanks for this one... I just want to ask If I can input the IP manually to running windows form? example this program run in my comp and my friend run also this program in his/her computer in the same local area network. thanks in advance.. more power to you mate...
i can't believe i sat here and watched the entire video while i don't know a thing about Programming#(THE power of Programming )
wow I was looking for it , to get an over idea about that topic , I'm newbie in network programming :D , than you so much sir
THANKS YOUR TUTORIAL WAS VERY WONDERFUL, THANKS A LOT!
very very thaaaaaaaaaaaaaaaanks@!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! :) love it !
Thank you,it was very interesting lesson))
How do you find out what port you or your friend is? Or all you need is their IP?
useful for me...is any changes have to be done while we connecting two computers through the Lan cable?....pls reply ..thanking you
hi sir..
app is working same pc but how it work with 2 pc
This really helped Ripon.
Very good video
Awesome tutorial!
Can you make a tutorial with this,
on how can I change font & color using fontdialog when I click the send.
I can change the font & color in textMessage but when I hit the send button it turns back to normal.
thanks in advance!
Whats with those distant screams and moanings ?!?!?
Rape
@@midobula4797 shut up
its a dog i think
shh...
@ your choice of music sucks ass
excelente video amigo, explicado muy bien, paso a paso
Hello, can I ask a question?
I want to Connect to Arduino by Wi-Fi address.
I write the Windows Form by C#, but I can't connect to the board.
Can you teach me? I am a rookie in C#, Please.
Hi Ripod, great tutorial man !!
I have a query regarding using this code for web app.
I have tried to use this code in web pages but getting error while sending msg at line
socket.Send(sendingMessage);
error msg is "A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied"
can you please help me out on how can I implement this for web application.
im facing the same problem did you get the solution?
Thanks a lot for this great video! If i wanted the message to be read out loud when sent how would i do this?
help!
System.Net.Sockets.SocketException: A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied
See in // binding Socket in epRemote, if you put sck.Bind (epRemote) or sck.Connect (epRemote), it may have put sck.Bind (epRemote) and it must be sck.Connect (epRemote).
@@nayanrangel7962 I have written same code but it said "an attempt was made to access a socket in a way forbidden by its access permission.
Good job,,but u have to reply the comments plsssssss,,,bcz there some people have some issues so clarify them
yeah that's great enhancement.
thank you so much !
Awesome work!
thank you very much !!
this is a good one !!
Thanks Fnoone, I will make this one.
Respect in Indian Nation restored
Ripon, I just subscribed, I would like to know the following. Is this specific to LAN networks, must it run over internet connection, and can it be done in a home/office setup?
Once again, good work brother, explain to the par. Thank you again, I know what I'll be doing this evening.
Sure. It can be run from your home or office setup.
hi i have a problem after i have open exe file there is a error like that "input string was not in a correct format" after i continue this message i create chat with other part of chat app after that i recieve that message box "a request to send or recieve data was disallowed because the socket is not connected and (when sending the datagram socket using a sendtro call)no address was supplied" s plz help me in this?
you may wrote txtLocalIp.Text instead of txtLocalPort.Text. Or the port text boxes are empty.
epLocal = new IPEndPoint(IPAddress.Parse(textLocalIp.Text),Convert.ToInt32(textLocalPort.Text));
I have a problem, i open 1 port at My Router, I sent to my friend IP Router and this Port.
My friend can chat with me by using Socket Chat Application, I also chat with myselft by using this.
But 1 program like as Skype or web as facebook not only don't need open a port, but also message is sent. I don't know how I do it?
Hope you give me more inforamation usefully, thanks
works on my machine, but cant get it to work with a co worker on the same network. Any Ideas? We configured everything correctly used his ip, and hit connect.. but no messages
Hey, how do i connect to other pc's to chat with and not with myself. As exmaple i want to chat with someone else in other place of my country, how to do, or is this only for local chat?
App in video will work, but only in the case when you and your friend have a static IP.
what is a static ip?
how to connect two difrnt mobil or computer at difrnt place without knowing each othrs port number but using same program as u instructed??????
hii, it says that something wrong and it gives an error if i start the exe and it says that the error is in this part of the code:
(sorry my english's bad im dutch 13)
System.Net.Sockets.SocketException (0x80004005): Een aanvraag om gegevens te verzenden of te ontvangen is niet toegestaan omdat de socket niet is verbonden en omdat (tijdens het verzenden op een datagramsocket via een sendto-aanroep) geen adres is opgegeven
bij System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
bij System.Net.Sockets.Socket.Send(Byte[] buffer)
bij chat.Form1.buttonSend_Click(Object sender, EventArgs e) in c:\Users\Gebruiker\Desktop\keylogg\chat\chat\Form1.cs:regel 98
bij System.Windows.Forms.Control.OnClick(EventArgs e)
bij System.Windows.Forms.Button.OnClick(EventArgs e)
bij System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
bij System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
bij System.Windows.Forms.Control.WndProc(Message& m)
bij System.Windows.Forms.ButtonBase.WndProc(Message& m)
bij System.Windows.Forms.Button.WndProc(Message& m)
bij System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bij System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bij System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
this is the original code that i've write:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
namespace chat
{
public partial class Form1 : Form
{
Socket sck;
EndPoint epLocal, epRemote;
byte[] buffer;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
//set up socket
sck = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
sck.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
//get user ip
textLocalIP.Text = "192.168.2.10";
textRemoteIP.Text = "192.168.2.10";
}
private string GetLocalIP()
{
IPHostEntry host;
host = Dns.GetHostEntry(Dns.GetHostName());
foreach (IPAddress ip in host.AddressList)
{
if (ip.AddressFamily == AddressFamily.InterNetwork)
return ip.ToString();
}
return "127.0.0.1";
}
private void buttonConnect_Click(object sender, EventArgs e)
{
//binding socket idk wat socket is
epLocal = new IPEndPoint(IPAddress.Parse(textLocalIP.Text), Convert.ToInt32(textLocalPort.Text));
sck.Bind(epLocal);
//connecting to remote IP
epRemote = new IPEndPoint(IPAddress.Parse(textRemoteIP.Text), Convert.ToInt32(textRemoteIP.Text));
sck.Connect(epRemote);
//listening the specific port
buffer = new byte[1500];
sck.BeginReceiveFrom(buffer, 0, buffer.Length, SocketFlags.None, ref epRemote, new AsyncCallback(MessageCallBack), buffer);
}
private void MessageCallBack(IAsyncResult aResult)
{
try
{
byte[] receivedData = new byte[1500];
receivedData = (byte[])aResult.AsyncState;
//converting byte[] to string
ASCIIEncoding aEncoding = new ASCIIEncoding();
string receivedMessage = aEncoding.GetString(receivedData);
//adding this message into listbox
listMessage.Items.Add("Friend: " + receivedMessage);
buffer = new byte[1500];
sck.BeginReceiveFrom(buffer, 0, buffer.Length, SocketFlags.None, ref epRemote, new AsyncCallback(MessageCallBack), buffer);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
private void buttonSend_Click(object sender, EventArgs e)
{
//convent string message to byte[]
ASCIIEncoding aEncoding = new ASCIIEncoding();
byte[] sendingMessage = new byte[1500];
sendingMessage = aEncoding.GetBytes(textMessage.Text);
//sending the encoded message
sck.Send(sendingMessage);
//adding to listbox
listMessage.Items.Add("Me: " + textMessage.Text);
textMessage.Text = "";
}
}
}
i've also the program virtual box and the program is grab the ip of that program so i write in the textboxes my true ip
greets jesse
Jesse Gerritsen Sorry I can't read your language of error message. If you could write it in English version, I would be able to figure out your error. Thank you. Keep in touch.
See in // binding Socket in epRemote, if you put sck.Bind (epRemote) or sck.Connect (epRemote), it may have put sck.Bind (epRemote) and it must be sck.Connect (epRemote).
make one more this add feature like transfer files... thanks man really cool video.....
i am very interested in this application:
1- any possibility to add attachment button ?
2- any possibility to have the code for this application ?
Many thanks
Hello Mr, Can you help me !
After Rebuild Solution, i run the program, has an error occurred : "Input string was not in a correct format ".
Meidheesh, you don't need to change anything in the code, you just put your IPs.
is this app work with two different network? like my office have different network and my home have different network,
pls upload any sharing site....good work
hi probably noone will respond but my messages dont appear in chat
Good video! You speak very good English!
hello Mr, I watched your tutorial and applied the same process but I want to add Memory Mapped File to the code. I couldnt do this. Can you help me to solve the problem?
If I tell you, I can't make the 'socket' function work in Visual Studio 12... any advice or corrections I may have to do?
Fantastic! thanks!!
I want to send files like audio,videos,image etc. may i get solution for this to implement this features in my chat application to send files.
i hve a doubt ........is that.. why u hve taken port no 80 or 81?......n if i wnt to use another port for communication to remote pc ....so i hve to check in command prompt that which port is valid or for communication or there is specific port like that u hve used?n i hve to enter remote pc's ip address & port no also .......for this how can i check remote pc's port no...?
hello sir....this application can use in two pc's using lan connection...??
Thanks ibell for your interest, if you use IP address like the given example then you will able to chat with your friends.
I have copied your code identically into a windows form using visual studio 2012 and I get an exception error on this line of code
epLocal = new IPEndPoint(IPAddress.Parse(txtLocalIP.Text), Convert.ToInt32(txtLocalPort.Text));
Input string not in the correct format. Any ideas
Thanks Bro! if possible then also make a tutorial for Group Chat!
This is nice! Thanks
Hello Mr, one Question pls, why when i run the program cant gate my ip like your test ?
Drino Duka follow the tutorial agian. Thank you so much. Write your voice or request in my site www.rdatta.com/You/YourVoice . Keep in touch with my site www.rdatta.com , www.f6build.com , www.di-ioc.com , www.codeffi.com and stay well.
I really like your tutorial, do you know how to add ÅÄÖ characters to work in this chat?
i know its something with the Ascii but I dont know how, thanks again!
Did you add the following namespaces? if not add this
using System.Net;
using System.Net.Sockets;
when i try to connect one error occured in my project FormatException was unhandled,
input string is not in correct format in this line epLOcal= new IPEndPoint(IPAddress.Parse(textLocalIp.Text), Convert ToInt32(textLocalPort.Text)); i give prot number 80 and 81 plz help me
Thank you
very nice tutorial...
Ripon Datta I NEED HELP!!!
THE NAME "textMessage" does not exist in the current context.
Check the name of your textBox for sending a message.
damn, you people must not have known c#
very nice tutorial (Y)
Tried this on 2 remote computers but it didn't work.
It works on my own computer like in your example though.
thank you very much bro... ;)
thanks :)
Hello Ripon Datta, I have a project Internet Messenger Desktop Application , Please can u make a video from User registration to Chat between client to client over internet and send message from server to clients , Only connected clients get message from server. and Logged in clients chat to each other. I am really very thankful to you.
Thank you very very very much
while ruuning this application sometime its work fine but in WHEN i run 2 exe on same pc and send message from one application to other it shows cross thread operation operation not valid :control listbox_messge accessed from a thread otther than a thread it was created own
Great tutorial man!
But there was an error in this code
string.receivedData = aEncoding.GetString(receivedData);
first receivedData is an error
what can i do?
did you found?
wonderful. but i've got a problem when i click "connect" its shows :impossible d'effectuer un cast d'un objet de type "System.Windows.Forms.TexBox"' en type "System.Iconvertible". Meanwhile i put the same values as you , for the ports. Can you help me please?
+Axel MOUELE In buttonConnect_Click, you have missed to Convert.ToInt32(textRemotePort.Text)) or Convert.ToInt32(textLocalPort.Text)).The ".Text" part specially, I did the same thing and got the same error. Try it out.
for me all the messages are blank it says friend: and nothing else
im using vb 2010 ultimate
Did you declare buffer as byte []buffer.
If not then only then you get such an error
Thank you so much
i get an error saying "the name MessageCallBack does not exist in the current context". is it to do with the fact that i'm using vs 2013?
Christos Karamanos Never mind i just spelled it wrong
Mines almost work this way but would I use the same code for getlocalip for getremoteid
OMG NVM IT WOKR TANK HEW THANSK WOWOWWOOW SUBBED
Can I connect it withe my friend's ip?
Can i use this same code if i lan two computers up ?
How can we connect it using a LAN cable between two laptops
please describe it briefly
thank you
Still the Same, if both of ur Laptops are connected to the Internet via LAN. Just use the IP Address of the Laptops
why did you callback'ed again at 19:00.. is it for recursively receiving the message from remote user as u have again passed the argument as MessageCallBack in AsynchCallBack().. doesn't it mean to be the recursive function?? :o Help..
Error CS0103 The name 'MessageCallBack' does not exist in the current context
help
Obrigado cara!!!
Jarede Santos Thank you. Keep in touch.
Ripon Datta Hello , you have a video chat on windows application using WCF technology? Thank you .
Thank you :D
Greetings;
I'm getting the following Error: "An Invalid Argument Was Supplied"
I've watched the entire Tutorial several times and Double Checked Everything.
Everything seems correct and i can't figure the problem.
According to the kind of Error Message the Problem lies under the "Connect Button" Coding.
protected void Button1_Click(object sender, EventArgs e)
{
//binding socket
epLocal = new IPEndPoint(IPAddress.Parse(textLocalIP.Text), Convert.ToInt32(TextBox2.Text));
sck.Bind(epLocal);
//connecting to friend IP
epRemote = new IPEndPoint(IPAddress.Parse(textFriendIP.Text), Convert.ToInt32(TextBox4.Text));
sck.Bind(epRemote);
//listening to specific port
buffer = new byte[1500];
sck.BeginReceiveFrom(buffer, 0, buffer.Length, SocketFlags.None, ref epRemote, new AsyncCallback(MessageCallBack), buffer);
}
Can Anyone Help me out in figuring this out?
Thanks in advance.
sck.Bind(epRemote) => sck.Connect(epRemote)