Library tutorials & articles
Introduction to TCP/IP
Introduction
With the acceptance of TCP/IP as a standard platform-independent network protocol, and the explosive growth of the Internet, the Windows Sockets API (application program interface) has emerged as the standard for network programming in the Windows environment. This document will introduce the basic concepts behind Windows Sockets programming and get you started with your first application created with SocketWrench.
SocketWrench is part of a package developed by Catalyst called the SocketTools Visual Edition. In addition to the comprehensive, but fairly low-level, access that SocketWrench provides, SocketTools includes components and libraries for many of the popular Internet application protocols, such as FTP, POP3, SMTP and HTTP. For more information about the complete SocketTools package, visit the Catalyst website at www.catalyst.com. It is assumed that the reader is familiar with Visual Basic and has installed the SocketWrench control. If you're already familiar with sockets programming, feel free to skip this section.
The Windows Sockets specification was created by a group of companies, including Microsoft, in an effort to standardize the TCP/IP suite of protocols under Windows. Prior to Windows Sockets, each vendor developed their own proprietary libraries, and although they all had similar functionality, the differences were significant enough to cause problems for the software developers that used them. The biggest limitation was that, upon choosing to develop against a specific vendor's library, the developer was "locked" into that particular implementation. A program written against one vendor's product would not work with another's. Windows Sockets was offered as a solution, leaving developers and their end-users free to choose any vendor's implementation with the assurance that the product will continue to work.
There are two general approaches that you can take when creating a program that uses Windows Sockets. One is to code directly against the API. The other is to use a component which provides a higher-level interface to the library by setting properties and responding to events. This can provide a more "natural" programming interface, and it allows you to avoid much of the error-prone drudgery commonly associated with sockets programming. By including the control in a project, setting some properties and responding to events, you can quickly and easily write an Internet-enabled application. And because of the nature of custom controls in general, the learning curve is low and experimentation is easy. SocketWrench provides a comprehensive interface to the Windows Sockets library and will be used to build a simple client-server application in the next section of this document. Before we get started with the control, however, we'll cover the basic terminology and concepts behind sockets programming in general.
Related articles
Events coming up
-
Jun
16
Code Generation 2009
Cambridge, United Kingdom
A developer event with a practical focus on helping people get to grips with code generation tools and technologies.
hi
This is possible using threads in the client program. the client can generate parallel connections using threads. so u can create multiple clients in the same system.
In the server side, you use two sockets. One for receive the data and another for response to corresponding clients. Use the FDSET, FDISSET functions to achieve this apps. This is reliable one
Hope I may answered your question.
Karthik
hi i want to make socket connection for the multiple clients like i want to send the data to the server to the multiple clients how i will be able to do that. IS there anybody else who can help me. I am able to do that by socket programming but only in single system when i want to do that on multiple system then it is not possible.is there any one? its very needed.................................... thanks and bye
Hi,
Iam developing the socket application.In this the remote host is sending messages.But iam not able to pick all the messages sent by the remote host.If remote is sending 10 msgs,then iam able to pick 2 or 3 msgs.pls tell me,what could be the reason for that asap.
Thank you.
there would b two applications one will be at server the other will be at client side
i m sending this code asuming that u have some prior knowledge about network programming
include this code at server side
Private Sub listen_Click()
Winsock1.LocalPort = 1002
Winsock1.listen
End Sub
Private Sub cmdsend_Click()
Winsock1.SendData chattxtbox.Text
txtwindow.Text = txtwindow.Text & vbNewLine & chattxtbox.Text
chattxtbox.Text = ""
txtwindow.SelStart = Len(txtwindow)
End Sub
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
Winsock1.Close
Winsock1.Accept requestID
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim txtwindowdata As String
Winsock1.GetData txtwindowdata
txtwindow.Text = txtwindow.Text & vbNewLine & txtwindowdata
txtwindow.SelStart = Len(txtwindow)
End Sub
//include this one at client siderivate Sub cmdconnect_Click()
Winsock1.RemoteHost = "127.0.0.1"
Winsock1.RemotePort = 1002
Winsock1.Connect
End Sub
Private Sub cmdsend_Click()
Winsock1.SendData chattxtbox.Text
rectxtwindow.Text = rectxtwindow.Text & vbNewLine & rectxtwindow.Text
chattxtbox.Text = ""
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim txtfromserver As String
Winsock1.GetData txtfromserver
rectxtwindow.Text = rectxtwindow.Text & vbNewLine & txtfromserver
rectxtwindow.SelStart = Len(rectxtwindow)
End Sub
Private Sub Winsock1_Connect()
MsgBox "Connecting to Server....Plz stay far n WAIT"
End Sub
this will make a client server chat applicatin with in a LAN
Hi. I read ur message. I'm doing a (socket programming) chatty client/server messenger program too and I need lots of help. I heard you have done it. Could u send me ur source code and i could refer to it. Thanks alot it will help me greatly. By the way i'm using tcp.
I ran into this problem a long time ago, what you need to do is throw in a DoEvents call in the place where your server is handling the incomming and outgoing traffic. I haven't made anything like that for awhile, but I'm pretty sure you do it in your loops, like:
example:
for each.. blah blah
Winsock1.SendData blah
DoEvents
end for
Hi...
im new to tcp programming using winsock control in Vusual Basic.
i tried a client server chat program, in which there is a client program running and its
communicting with a server program. when i tried with two clients communicating thru a server program..its not working...can you help me....please send the source code also..
By
Faisal
I only speak a lite bit of English
I need to know the name of the file on Windows to define a
new LocalPort (UDP port) for a new application (Client/Server) of
Files.
Mi lenguaje es el Castellano.
Thanks Javier
If you're using SocketWrench, there's an HTTP client and server example that's included that could probably serve as a foundation for what you're interested in doing. If you have any specific questions, I'd be happy to answer them for you.
I am a new member and my question might have been asked before but i can not find it in the archives.
But if anyone would be able to help, please do. I would be greatful.
Q: I have to create a (http like) protocol to enable the client communicate with a server. I know the basics but would be greatful for any ideas. Thanks
How are you broadcasting? Are you using TCP/IP or UDP? I have sent broadcast messages using UDP just by using the broadcast address 255.255.255.255 so that the packet goes everywhere. I had problems prior to using this when the PC's were in different domains. I dont know if this helps!
i created a client/server application using winsock, and everything works fine except if i try to send a message to all the clients from the server, only the last client actually recieves the message. after much research i found the service pack 4 for VB resolves this issue...but it only resolved the issue if i use my computer (that has VB) as the server.... i need to use a computer that does not have VB to be the server. Can anyone help me!!!!!