Carlosky - Basic TCP Server and Client in VB.NET WinForms

  Рет қаралды 20,534

Carlo Da Silva

Carlo Da Silva

Күн бұрын

Пікірлер: 62
@dylanobrien462
@dylanobrien462 3 ай бұрын
Thanks man still works perfectly 8 years later and is super clear on why this works and how tcp talks to each other. Great video
@carlodasilva7839
@carlodasilva7839 3 ай бұрын
@dylanobrien462, I'm glad to hear that! The code is a little outdated now and I've since discovered better ways to write it, but at least this should help get people where they need to go. Thank you for the comment!
@MarkAzali
@MarkAzali Жыл бұрын
Thanks for this sample. It helped me!
@carlodasilva7839
@carlodasilva7839 Жыл бұрын
Glad I could help!
@Malc2169
@Malc2169 6 жыл бұрын
Brilliant! Works straight out of the box - many thanks!
@carlodasilva7839
@carlodasilva7839 6 жыл бұрын
Hi Malc, Glad I could help!
@tinblue
@tinblue 4 жыл бұрын
Fantastic. Thank you
@carlodasilva7839
@carlodasilva7839 4 жыл бұрын
It's a pleasure!
@noshairfarooq4032
@noshairfarooq4032 7 жыл бұрын
can't thank you enough man.. keep up the good work (y)
@carlodasilva7839
@carlodasilva7839 7 жыл бұрын
Hi! Glad I could help!
@noshairfarooq4032
@noshairfarooq4032 7 жыл бұрын
Hello! your code works great but can you help me with what change i need to make if the server and the client are on two different computers? what IP and port i need to assign so that both can communicate over the same network but on different computer, will be really thankful if you could help.
@carlodasilva7839
@carlodasilva7839 7 жыл бұрын
Ok so you'll need your Internal IP. To get that, just press the Windows Key + R. Then type 'cmd', without quotes and press enter. That will open Command Prompt. In Command Prompt, type 'ipconfig' and press enter. Depending on whether you are connected via WIFI or LAN Cable, you will need to check your IPv4 Address field. The IP for your LAN connection, will be under Ethernet Adapter and the one for WIFI will be under WIFI Adapter. Once you have the IP, you can then edit the Server and Client applications so that it prompts you to enter the IP and Port. So where the current IP is in the code, you would add textboxes on your form and change the IP section to Dim ip As String = TextBox1.Text and the same for the port... Dim port As Integer = TextBox2.Text... So then you need to run the server on one of the machines. And you need to use the IP of the machine where the Server will be running... So if your IP is 192.168.0.5 on pc1 and 192.168.0.6 on pc2, if you are hosting the Server on pc1 then the server IP will be 192.168.0.5. All machines, including pc1 will then run the Client application and that will also prompt for an IP and Port. That is when you put in the IP and Port of pc1 which is the one that is hosting the Server. The Port can be anything you want, but must be between 0-65535 and can't already be used by another program. You will get an exception when trying to use the same port as another application. Also just check my response to Amoeba Man as he also asked me a similar question to yours. There I also explain how you can get it to work over the Internet too! Let me know if this cleared things up for you!
@noshairfarooq4032
@noshairfarooq4032 7 жыл бұрын
hey it worked (y) thanks mate . one last thing i want to bother you for.. is there a way to write a stream with the tag name? like if want to send 2 different types of information to the same client.
@carlodasilva7839
@carlodasilva7839 7 жыл бұрын
Noshair Farooq OK so if you want to send the name and text, you can do so like this: Dim toSend As String = "Noshair|Hello!" Then you convert it to a byte array and when you send it to the server it will just send it to the client... Then on the client side, you then convert the byte array back to a string... Now on the client side you will have "Noshair|Hello" what you do now is split it on the "special" character and then you will have the name and the message you sent across... And to split it you do this: Dim cmd As List(Of String) = "Noshair|Hello".Split("|") Now you will have to things in your list! And you can access them by doing this: cmd(0) for the first one which is the name and cmd(1) for the second one which is the message... Hope that helps...
@kevnar
@kevnar 7 жыл бұрын
Can you do a tutorial on file transfering? If you wanted to send a pic or txt or whatever over this same system, how would you do that?
@TIPDYT
@TIPDYT 3 жыл бұрын
You can use an FTP server. I've done that and it worked!
@yotoprules9361
@yotoprules9361 4 жыл бұрын
Hi, how I can I stop the server? I've been trying to make a stop button but I always get this error: "A blocking operating was interrupted by a call to WSACancelBlockingCall"
@jainahsadaya5651
@jainahsadaya5651 3 жыл бұрын
How to send data to specific IP only?
@rakeshreddy2623
@rakeshreddy2623 4 жыл бұрын
once you start the server the form is not moving but i want the server form to move and remaining actions should take plce in paralel
@thegoodmanforeal
@thegoodmanforeal Жыл бұрын
Download link to WinForms Version is invalid. Please help.
@carlodasilva7839
@carlodasilva7839 Жыл бұрын
Hi, it seems that after many years of the code being on my Google Drive, Google just decided to flag it because I had the .exe pre-built for your convenience... I've removed it from the files, so you'll have to build the project yourself, by opening it in Visual Studio. I even had to convert it to .NET 4.8, just because that's what I have currently... Hope this helps.
@thegoodmanforeal
@thegoodmanforeal Жыл бұрын
@@carlodasilva7839 Thanks a lot, the download link has been fixed now. Have a great day!
@gameplayoffert1326
@gameplayoffert1326 4 жыл бұрын
hi, your tutorial work very good thx you but i have a question ? i want to send a "15 go" file but the byte is limit to "32 bits integer" so how can i send my file ? i have check your comment and you say "you need to split them" ok but how ?
@carlodasilva7839
@carlodasilva7839 4 жыл бұрын
Hi Gameplay Offert, Uhmmm... I looked around on KZbin for other tutorials on file transferring using TCP and I must say, they can get a bit complex. I have written my own file transfer application years ago and I had the same limitation as what you are mentioning. I think I could only send files up to 2GB in size and only at a speed of 1MB/s. I didn't really improve on it as I didn't actually end up using that application much. The 2GB max size limitation isn't as much of a concern to me as the max speed is. But yes you have a 15GB file you want to send. I'll have to be straight with you and "you need to split them" sounds easy but isn't actually that easy. The thing is, to do it the right way, will actually require a long video as there would be a lot to explain. I'm actually not happy with this code I wrote 5 years ago. It's actually not that good. That's also because I didn't know as much back then as I do now. I think what I need to do is restart from scratch and make it more of a series. So re-make this video as just a basic on how to get communication between applications and then I will have include file transferring in a future video. I don't know how long it will take me to get there as there are a couple of things I need to figure out before being able to transfer large files at higher speeds. Then again if and when I get there, essentially it would be like making a Torrent application. Not sure if you know what Torrent applications are, but their purpose is to do file transfers without losing progress even if you restarted your computer. I'd like to do the same, but getting to that point will take time. If you are willing to wait let me know and I can try give it a shot!
@gameplayoffert1326
@gameplayoffert1326 4 жыл бұрын
@@carlodasilva7839 hi, yes don't worry i know what is Torrent program (Utorrent, Bitorrent) i see what you mean and for losing progress yes it's the same of "Torrent Program" but not only it's same with "Steam , Uplay" and other plateform you can download a file and if you restart your computer a 12gb/15gb you can continue at 12gb to 15gb and i want to do the same thing so yes i'm ready to wait and when you send the file it's limited to 1/mb ? i understand now why the file transfer is too long so if you can explain me why ? and what you do now that can be interesting so thx.
@carlodasilva7839
@carlodasilva7839 4 жыл бұрын
​@@gameplayoffert1326 ​ I don't actually yet know how to resolve my 1MB/s limit, but I think I have a few ideas that might solve it, but will need to run tests. If the code that I used in this video did not have size limits (for the data that is being sent/received), the speed would be unlimited (something else would have limted the speed, e.g. your Internet speed). But at the time of me making my own file transferring application, I used different code and that was processing data 1 byte at a time. I suspect that because I was only processing 1 byte at a time, it caused it to be slow and limit it to 1MB/s. Also, the way I had built it did not allow me to continue the download if it had stopped at any point, so you had to make sure the connection was stable. The reason I was processing only 1 byte at a time was because I wanted to show the progress of the download and couldn't figure out a different way of doing so at the time. But ok, I will have to start from scratch so that the foundation of the code will be stable. I'm not 100% sure when I could upload the "new" video (same as this one, but better and more stable), but will hopefully try get it done sometime during the upcoming week. I also have a normal job, so that's also why it will take time to get this done.
@carlodasilva7839
@carlodasilva7839 4 жыл бұрын
@@gameplayoffert1326 Hey, I managed to resolve the 1 MB/s limit and you can also send any file size. I don't think I'll be coming out with the refresh of this series, as I had mentioned, because life has been a bit rough lately. I do however have the code and I can give it to and explain what it is doing. There might be a time where I'll make videos again, but maybe not now. I'd like to still help you so join my Discord server and we can chat there and I can screen share with you to explain what I did and how it works. This will make it easier. Here is the Discord Server: discord.gg/hXykhjJ
@tonylane1308
@tonylane1308 5 жыл бұрын
Hey, awesome video! I have some confusion with some aspects of it. I used the code in this video and put it into separate classes. I get an error that says, "Object reference not set to an instance of an object". I can't figure a possible solution to this. And another question I had was, can you run both the host and connection at the same time within the same form?
@carlodasilva7839
@carlodasilva7839 5 жыл бұрын
Hi Tony, are you instanciating your classes before you try to use them? I think that's why you are getting the Object reference error... Regarding putting both the Server and Client in one app, that is very much possible! If you want, you can send me the code you have and I can fix the Object reference errors... or we could setup a TeamViewer session and I can show you what to do? Also, I could then also show you how to send files across too... Very easy to do too... If you're interested in setting up the TeamViewer session, let me know and we can make a plan...
@tonylane1308
@tonylane1308 5 жыл бұрын
Yeah we could do teamviewer. Haven't messed with that feature though
@carlodasilva7839
@carlodasilva7839 5 жыл бұрын
@@tonylane1308 Hi Tony, I replied to your message, but my reply is not here... Weird... Do you still need the help?
@davidlinda7462
@davidlinda7462 7 жыл бұрын
I receive to following error: Unable to read from the transport connection. An existing connection was forcibly closed by the remote host It occurs when the clients are closed. I tracked the location to the SERVER code in the newClient sub I am running Win 10 Home and vs 2008 Thanks in advance for you help
@carlodasilva7839
@carlodasilva7839 7 жыл бұрын
David Linda is that on the server or client?
@carlodasilva7839
@carlodasilva7839 7 жыл бұрын
David Linda oh wait I see... Yes the server will give out that error because when you close the client, it kills the connection to the server... What you can do is send the server a kill mesaage, the same way you send text and if it is something like "Disconnect" then you close the client on the server side... I haven't really tried it, if it is that specific error, it can be ignored because it doesn't break anything... But you can also get that error when your network is interrupted... But if you leave it in an empty catch or if you check for that specific error and let it through, that's also fine...
@amoebaman4057
@amoebaman4057 7 жыл бұрын
@Carlo Da Silva can you explain how I could make this setup work across two computers? Thanks
@carlodasilva7839
@carlodasilva7839 7 жыл бұрын
Amoeba Man Hi, Step1: get the IP of the PC you want to host the server Step2: allow the IP and port to be changeable... By that I mean add two textboxes on your form and set Dim IP As String = textbox1.text... And same for the port... Then when you click the button, it would then use the newly entered ip... Step3: do that for server and client Step4: copy the clients on any other PC connected to the same network... Step5: start the server on which ever PC you want to host the connection from... Step6: connect to the server using the server IP and port Step7: and that should be it! If you want to use this app over the internet to chat with a buddy that is not on the same network as you, you can check out a port forwarding video I made explaining how to port forward! Once port forwarded, then you follow these same steps just that the IP we were using in this example was the Internal IP... For you to connect over the internet, you need to use your External IP... If you just type in Google external IP, it should give you yours... Hope the explanation helps. Let me know if you need anything else...
@carp7085
@carp7085 6 жыл бұрын
Hi, may I know as for step 2's implementation should be done on Server or Client window's form? Thanks
@1lucak1
@1lucak1 8 жыл бұрын
What does the underscore mean? For example _server ?
@carlodasilva7839
@carlodasilva7839 8 жыл бұрын
Hi Luca, The underscore means absolutely nothing... I only use it to indicate a global variable... It is usually good programming practice to do something similar... Cause then, when you are using a variable and have lots of code, you can easily spot which variables were created in the function you're in and which have been created globally... Hope this helps! And also, you make all variables start with a lower case... Functions, Subprocedures and Properties, should always be with the initial character upper case...
@1lucak1
@1lucak1 8 жыл бұрын
Carlo Da Silva I knever thought of this, really clean coding as I think about it now :-)
@carlodasilva7839
@carlodasilva7839 8 жыл бұрын
Luca, well that's what you want... Cause once your program starts to grow, it will get harder to read... But if you put down a system like that, it becomes easier to read and more intuitive... And also, you can pretty much ask any programmer, if you make something and leave it for a while, you forget what you've done... So the easier it is to read, the better... And also make sure to make comments in code for the more complex stuff...
@1lucak1
@1lucak1 8 жыл бұрын
Carlo Da Silva I know how important a clean code is in a big project. But I never thought of a way like this. Nice :)
@JamesKulwicki
@JamesKulwicki 7 жыл бұрын
Are you still developing this?
@viralfocus10
@viralfocus10 8 жыл бұрын
Can u show how to use combobox?
@carlodasilva7839
@carlodasilva7839 8 жыл бұрын
Hi Booted, I don't recall ever getting a notification of your message... Sorry for the very late reply... Could you specify further about what you mean? As in, what would you like to see in a combobox? Or do you just want to know how a combobox is used?
@cambodeeritnews5629
@cambodeeritnews5629 3 жыл бұрын
is it 2 projects man? 1 for server main form and 2 for client form1? really!
@carlodasilva7839
@carlodasilva7839 3 жыл бұрын
Hi CamboDeer, yes the only reason I did it that way was to show that there is definitely nothing suspicious going on, this way shows that none of it was faked... but you can just as well have all of it in 1 application... hope that answer helps...
@pravar1581
@pravar1581 6 жыл бұрын
That’s cool But can we do in two or more different systems/ computers
@carlodasilva7839
@carlodasilva7839 6 жыл бұрын
Hi Pravar, I'm sorry to say that I wouldn't be able to help with that as I code in .NET... For you to achieve this you would need to know multiple programming languages, but even then, the code will be completely different as different languages have different frameworks that they work on.
@CrystalDreamEntTV
@CrystalDreamEntTV 4 жыл бұрын
Not sure if you are still coding, but please respond with a way to email/contact you. As I would pay you for your time/knowledge to assist me in what I want to do with my application. Thanks. -Stavros
@carlodasilva7839
@carlodasilva7839 4 жыл бұрын
Hi Stavros, I do still code but haven't kept my YT up as much as I'd have liked to. I have a Discord for my Twitch. You can join the Discord and we can chat on there more privately if you'd like. Don't want to leave my email in the comment section. If you don't have Discord, let me know and will try think of another way we can get in contact... Discord: discord.gg/hXykhjJ
@chxwwy1709
@chxwwy1709 6 жыл бұрын
First of all I do not blame anyone! I downloaded the program and said that Attım and Avast on the desktop are the virus of the program! Why is it? I'm using translation
@carlodasilva7839
@carlodasilva7839 6 жыл бұрын
Maxi Hi Maxi, that is very possible since the application uses your network... And that's how most viruses work... They get onto the PC and then call home... Then the creator can then do stuff on the machine... At the end of the day I can guarantee that there is no virus in there, but I guess everyone would say that... But if you don't trust the file and have Visual Studio, then just create it as it is in the video... At the end of it you might have your AV also moan at it too... Either way the file has the source code... So you can check exactly what is there... Maybe delete the Bin folder, since that contains the .exe, and then recompile it with VS if you have it... But really, the file is super clean... I've also noticed that sometimes the AV warns about the file because it is not certified... And so it then sends a sample back to get analyzed... That might be what happened...
@chxwwy1709
@chxwwy1709 6 жыл бұрын
I know all about your right friends and I do not know if there's a virus Actually there is no problem I just want to write Thanks Again :)
@carlodasilva7839
@carlodasilva7839 6 жыл бұрын
Maxi it's a pleasure Maxi!
@chxwwy1709
@chxwwy1709 6 жыл бұрын
:) Bye
Carlosky - Basic TCP Server and Client in VB.NET Console application
17:16
NE #66 How to code TCP Client and GUI in Visual BASIC 2017: Accessing Xena Gig test set API
23:38
PRANK😂 rate Mark’s kick 1-10 🤕
00:14
Diana Belitskay
Рет қаралды 8 МЛН
Человек паук уже не тот
00:32
Miracle
Рет қаралды 4 МЛН
Human vs Jet Engine
00:19
MrBeast
Рет қаралды 200 МЛН
Client Server programming in VB.NET ( Chat application )
22:00
Coding World
Рет қаралды 20 М.
The Right Way To Return API Errors in .NET
10:40
Nick Chapsas
Рет қаралды 44 М.
TCP Socket Tutorial (C#, Visual Studio, Networked Console Apps)
16:24
wolfs cry games
Рет қаралды 57 М.
The Value of Source Code
17:46
Philomatics
Рет қаралды 198 М.
Making A WebSocket Server With .NET 8🧑‍💻  [FULLSTACK 2024 VIDEO 1]
18:43
Alex's Dev Den 👨‍💻
Рет қаралды 13 М.
КАК УСТРОЕН TCP/IP?
31:32
Alek OS
Рет қаралды 209 М.
C# Socket Programming - Multiple Clients
29:08
Brian (Able Opus)
Рет қаралды 362 М.
PRANK😂 rate Mark’s kick 1-10 🤕
00:14
Diana Belitskay
Рет қаралды 8 МЛН