How to use winsock control in ASP.Net using VB.Net 2003?

I have to use winsock control in my ASP.net application. And don't have any idea to use it in ASP.net, but I have used it previously in VB.Net project. What I did in ASP.net  is-----
I added its reference and also added it in toolbox. But it got added in Windows Forms section of toolbox.
I dragged winsock control from tool box to a webform and named it as win1, then in code behind(i.e. aspx.vb) I tried to use it by typing win1 then one dot( . ) but it has not given any intellisence.
So how could use winsock control in ASP.net.
Can any send me link to a dummy project in which winsock is used(In ASP.net using VB.Net 2003 only) so that I would have some idea of using winsock in ASP.Net 2003.
And also explain me how to add its control in toolbox.
And why I am not getting intellisence?
Please note that I have to use winsock in ASP.net project using VB.Net and not in core VB.Net.
As when I googled this I got all the project in core VB.Net only.
0
harshal_shravgi
1/15/2007 6:34:59 AM
asp.net.getting-started 91979 articles. 3 followers. Follow

20 Replies
847 Views

Similar Articles

[PageSpeed] 27

What is it you are trying to do? Perhaps there is a better way. Here is an article on using HTTPWebRequest to get data from the web, just on the off-chance that it's what you're trying to do.

Here is another article that I think directly addresses your issue.

 

0
Markbnj
1/15/2007 7:02:31 AM

We have one device called call manager. Four Phones are connected to this device, whenever receiver of any othe Phone is picked up it will send some data to the winsock and I will display that which phone's receiver is picked up.

Actually I have did this in VB.net but not able to do same thing ASP.Net as I neither getting any events of that win1 nor any intellisence at code behind.

0
harshal_shravgi
1/15/2007 7:26:51 AM

Is there anyone who has used winsock control in asp.net?

How to use it?

0
harshal_shravgi
1/16/2007 6:51:40 AM

Ok now I am using one component called Ostro Soft's Winsock Control.

I added its reference then defined it in code as -

Dim WithEvents Wsk_1 As New OSWINSCK.Winsock

Also opened that socket as - Wsk_1.RemoteHost = "190.168.14.21" : Wsk_1.RemotePort = "3001" : Wsk_1.Connect()

Private Sub Wsk_1_OnDataArrival(ByVal bytesTotal As Integer) Handles Wsk_1.OnDataArrival
   lblError.Text = "Call Received"
End Sub

I received data i.e. above sub-routine is called, but that text of label didn't changed.

Why that text of label didn't changed?

0
harshal_shravgi
1/18/2007 6:36:28 AM

I thing I have mistaken socket programming. Actually I am mixing up core VB.Net and ASP.Net's concept of socket programming.

In VB.Net we use used create a socket and display data when some data is received on socket as the software is installed on the machine which is directly connected to our call manager device.

But in ASP.Net the web server is directly connected to that device, so server will receive data and that data should be displayed on client's web page.

Am I right? I am still confused about socket programming.

Is there anyone who have used sockets in ASP.Net application?

0
harshal_shravgi
1/19/2007 4:50:45 AM
hi,

I have used tcpclient and tcplistener in a ASP.NET application before. What i did was to create a class file (in my case it is in VB). Create your required socket communication in the class file.

In the ASP.NET application, call the methods from the class file. It should work.
0
onepieceking
1/19/2007 8:26:28 AM
Could you please tell me what you did in detail? Or could you send me any link to study this?
0
harshal_shravgi
1/19/2007 1:03:33 PM
Hey onepieceking, could you please send me any link related to this?
0
harshal_shravgi
1/20/2007 5:15:24 AM

Hi,

It is very similar to what you would do for a window application except this time you create the codes into a class file.

I use this link http://www.eggheadcafe.com/articles/20020323.asp for the start.

 

0
onepieceking
1/22/2007 1:23:46 AM

I am not getting that code. Actually I need not create TCPListner I want client only, also i don't want to send any thing to the server.

I just want to connect a socket to an IP Address(i.e. to our electronic device). Then that device will send some data to this client then I will process that raw data and sort out phone no. and call type through it and that phone no. I want to display on web page.

How could i use that class file in my code behind?

 

0
harshal_shravgi
1/22/2007 6:39:42 AM
Hi, then you can use System.Net.Sockets.TcpClient class.
0
Raymond
1/22/2007 8:34:42 AM

I created one class file as follows -
Imports System.Net.Sockets
Imports System.Text
Public Class TCPCli
    Public Function Fun_Connect() As String
        Dim tcpClient As New System.Net.Sockets.TcpClient
        tcpClient.Connect("192.168.1.187", 3017)
        Dim networkStream As NetworkStream = tcpClient.GetStream()
        If networkStream.CanWrite And networkStream.CanRead Then
            Dim bytes(tcpClient.ReceiveBufferSize) As Byte
            networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
            Dim returndata As String = Encoding.ASCII.GetString(bytes)
            Fun_Connect = "Host returned: " + returndata
        Else
            If Not networkStream.CanRead Then
                Fun_Connect = "cannot not write data to this stream"
                tcpClient.Close()
            Else
                If Not networkStream.CanWrite Then
                    Fun_Connect = "cannot read data from this stream"
                    tcpClient.Close()
                End If
            End If
        End If
        Console.ReadLine()
    End Function
End Class

And in my project's code behind i used above file as follows -

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        btnClose.Attributes.Add("OnClick", "CloseForm()")
        Dim obj As New SocketTest.TCPCli
        Dim str As String
        str = obj.Fun_Connect
        If str <> "" Then
            Response.Write("Data received")
        End If
End Sub

But getting error at line -  tcpClient.Connect("192.168.1.187", 3017) and error is - No connection could be made because the target machine actively refused it

0
harshal_shravgi
1/22/2007 11:29:37 AM

Hi,

It means the other side, that you are trying to connect to, is not listening at that port or it is not listening at all.

By the way, the code seems okay. Check the other side.

0
onepieceking
1/23/2007 1:17:39 AM

The web page got hanged for about two minutes after that gives error - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

I am receiving data on same IP Address and port No. in my VB.Net application.

 

0
harshal_shravgi
1/23/2007 6:33:09 AM

hi,

Are you testing both asp.net and vb.net application on the same computer? If so, maybe you can try changing the IP address for both applications to "127.0.0.1".

0
onepieceking
1/24/2007 1:14:25 AM

No firstly I tested on separate computers in same network. Then I tested on same computer also.

When I use Ostro Soft's Winsock Control I receive the data but there is no change on web page. Could u please tell me why so?

0
harshal_shravgi
1/24/2007 4:43:26 AM

Let me tell you my problem again, actually I want to implent live monitoring.

On my web page I have taken one datagrid, in this firstly I display list of phone nos and our channel nos and establish connection of one socket with our 'call manager' device. Thats it.

Now suppose after half an hour we got a call (incoming call) then that 'call manager' will send us some raw data to which we will process in our code and find out on which phone no. we have got that call and then we will display 'incoming call' in front of that phone no. in our datagrid.

Using Ostro Soft's winsock control I am receiving data at socket but when I bind that new data to datagrid then there no change in it. So then I simply written the above code to change text of label. But it is also not working.

Do I need to automatically refresh the page to apply these changes?

If so then how could I refresh the page automatically? Should I use timer control? I don't how to use timer control.

Or simply tell me some other methods to implement live monitoring. The code given above that use TcpClient is of no use for me because they gives results when they receive instant reponse from TcpServer but in my case it is not sure that when will that server (or 'call manager device') send data. It may send data after 15 minutes or after 30 min. or 1 hour or will not send data for whole day.

I have seen something like SNMP protocol to do this. What is it? Is it helpful for me? Is there anyone who is using it?

0
harshal_shravgi
1/27/2007 5:29:46 AM

Please tell me one thing - If I create TCPClient in ASP.Net application and TCPServer in core VB.net application then whether they will be able communicate with each other.

Also ASP.net application and VB.Net application will be running on different machines but communicating on same port.

Is it possible?

0
harshal_shravgi
2/3/2007 6:18:15 AM

Hi,

They should work. That was what I did last time. TcpClient in a VB.NET class for ASP.NET web application and TcpServer for core VB.NET application.

 

0
onepieceking
2/6/2007 1:20:18 AM

Sorry,

Correct me if I am wrong. When you say ASP.NET and VB.NET in different machines, I am taking it as the web server and VB.NET application are in the same machine and that you are accessing the web server from another machine.

0
onepieceking
2/6/2007 1:24:22 AM
Reply:

Similar Artilces:

Sending SMS using vb.net or C#.net using vb.net or c#.net
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

use VB.NET and C#.NET code in the same C#.NET project
All-- Here is a sample that is "off the beaten path", (at least for me). Is it possible, in an ASP.NET application, using the code-behind page building technique, to have both pages written in VB.NET and pages written C#.NET?At http://www.WebLogicArts.com/DemoList.aspx there is a sample that shows that, (contrary to popular belief), it IS possible to mix ASP.NET pages built with C#.NET with ASP.NET pages built with VB.NET in the same VS.NET 2003 project. Note that this is just a "fun" sample to see if it can be done and I do not recommend this practice as a "standard" way of develo...

use of vb.net and c#.net
i make a small website using vb.net,  in it i make a 2 class in C#.net. that i want to use in that website, i dont know how to call that class. let your class is  - class clsMyClass    {        public void myFunction()        {            // do something        }    } now the first way - create objectclsMyClass myObj = new clsMyClass();myObj.myFunction(); // call function================...

Issue using control created in VS.net 2003 in VS.net 2002
I have a friend that has an issue using my asp.net C# custom control in Visual Studio.net 2002 that I have compiled under Visual Studio.net 2003. I never did test it with that version, but I was under the impression that it should still work as long as you don't use any features specific to the 1.1 framework (which I really don't think I did). My guess now is that this is correct, but only when using 2002 controls in 2003. I have searched the web, these forums, and MSDN for the last 30 minutes with no real answer. The guy that runs MetaBuilders (http://www.metabuilders.com/Faq.aspx) tell...

used a c#.net to vb.net converter and am now getting a syntax error.
ok I used a cool utility at http://www.kamalpatel.net/ConvertCSharp2VB.aspx to convert some c#.net to vb.net and it spit out a bunch of code which almost works but I am getting a syntax error on this line Imports (StreamReader sr = Shadows Function)() As StreamReader(objResponse.GetResponseStream()) I tried it that way and also like Imports (StreamReader sr = Shadows Function)() As StreamReader(objResponse.GetResponseStream()) but either way gave the same error Compiler Error Message: BC30035: Syntax error. Source Error: Line 26: Line ...

Problem with Oracle Stored Procedures using ODP.NET in VB.NET (VS 2003)
This is the stored procedure,Procedure RetrieveReservations(pProperty In Varchar2,pResHeaderId In Varchar2,pEmail In Varchar2,pPasswd In Varchar2,ResultSet In Out ResCursor);This is the old .asp code (part of it)objConn.ConnectionString = Application("BackEndConnection_ConnectionString")objConn.Open objComm.ActiveConnection = objConn objComm.CommandText = "internet_package.RetrieveReservations"objComm.CommandType = adCmdStoredProc objComm.Parameters.Append objComm.CreateParameter("pProperty", adVarChar , adParamInput, 8, Request.QueryString("propid"))objComm.Parameters.Append objComm.Crea...

How to get new web app to use .NET 2.0 on Win2K server using .NET 1.1 as default framework?
I have .net framework1.1 and 2.0 on our server running win2K. i have existing applications that uses asp.net 1.1, i also have a new app that use ASP.net 2.0.  how can i set my new .NET 2.0 app to point to asp.net 2.0 without messing up my existing .NET 1.1 apps? To specify the ASP .Net version fro a web application, do the followingIn IIS Manager select the web application -> Properties -> ASP.Net TabSelect  ASP.Net version you want to use for the applicationRegards,PrashantDont forget to click "Mark as Answer" on the post that helped you. But I am running Win2K...

How to use InterBase with VS.NET (vb.net)??
Hi all; Q1:How can I use "InterBase" as a RDMS with Visual Studio.NET (VB.NET) for developing a small application?? Q2:What should I use for a Data Provider? Q3:How ConnectionString will be build?? Thanks in advanced!Regards,CS4Ever~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Dont forget to click "Mark as Answer" on the post that helped you.This credits that member, earns you a point and marks your thread as Resolved so we will ALL know you have been helped. This will help me, you and others....

.Net 2.0 Web application using Vb.net is unable to create object of another dll writen in C# .net 2.0
Hi, I habe created one ASP.net web application using Vb.net which is adding reference of dlls written in C# and .net 2.0. But whenever trying to create object of referencing dll, it is throwing error :Object reference does not set to an object. But, locally it is working fine,. In the server i have deployed the .aspx files and dll files in the bin. There were already an web.config in the server which is of .net 1.1. But checked it is retrieving value for that web.config correctly. Should i have to deply any other files and if not what can be the solution for this? Please help. Thanks, So...

how can i write this line using vb.net : container.dataitem ?.... in vb.net its not working
Dim container As GridView = CType(newLinkButton.NamingContainer, GridView) Dim dataValue As Object = DataBinder.Eval(container.dataitem, _ColName)   _ColName its just a string a name of the field in my database   This is Vb.Net code man what you want? You can convert any format from this link http://www.developerfusion.com/tools/convert/vb-to-csharp/  If this post is answer of your question then don't forgot to Click Mark As Answer...

Re: Gadget using vb.net and c#.net
 Hi, I am new to Gadget Concept. i want to create new Gadget. it must show the name 'Gadget Application'. pls, guide me how to create Gadget using .net application with some sample. thanks for your help in advance. Regards,Suriyanarayana.N  Unfortunately creating a Gadget using the .NET framework is not so simple. I have found a few post that might help you understand the process:http://www.codeproject.com/KB/gadgets/gadgettips.aspx http://www.codeproject.com/KB/gadgets/GadgetInterop.aspx Gabriel Bogéa (http://www.gbogea.com)-----------------Please 'Mark...

Insert datetime, using ADO.net VB.net
Hello there,I got a little code there are inserting a record into my msSQL database..But i cant insert the datetime, for one reason?The problem is in line 7 () where i want to insert DateTime.Now 1 Protected Sub SendPmTilAfviste(ByVal modtager As String, ByVal festID As String) 2 ' Connection 3 Dim conn As SqlConnection = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True") 4 conn.Open() 5 6 ' SQL-kommandoen 7 Dim cm...

Cross-Platform .NET Development: Using Mono, Portable.NET, and Microsoft .NET
Interesting book I came across: Cross-Platform .NET Development $49.99 doesn't hurt too much either :) NOTE: Availability: This item has not yet been released. You may order it now and we will ship it to you when it arrives. It's being released on September 30th, 2004 - one to keep an eye on...www.codingmayhem.com - VB.NET, C#, Silverlight, Javascript, HTML, CSS, T-SQL, MySQL and SQLitewww.headshotgamer.com - Gaming News and Reviews How about this book from Oreilly? Mono: A Developer's Notebook http://www.oreilly.com/catalog/monoadn/...

How to use net use?
Please can any one tell me how to use the dos command net use properly? I have read the help but can't seem to get it to work. Keep getting sytax error message. Thanks in advance. "Beowulf" <who-knows@no-one.com> wrote in message news:9krutk$puu$1@news.grc.com... > Please can any one tell me how to use the dos command net use properly? > > I have read the help but can't seem to get it to work. Keep getting sytax > error message. what are you trying to do? There are about 50 options to "net use" that do a ton of different thin...

How to Add Applications to ADAM using vb.net or C#.net
 Hi Pls thrown light  any one on How to Add Applications to ADAM using vb.net or C#.net RegardsMallikarjunaP.Mallikarjuna...

Web resources about - How to use winsock control in ASP.Net using VB.Net 2003? - asp.net.getting-started

Winsock - Wikipedia, the free encyclopedia
In computing , the Windows Sockets API (WSA) , which was later shortened to Winsock , is a technical specification that defines how Windows network ...

Thanks for Trumpet Winsock - Recognising an unsung hero
Recognising an unsung hero Do you remember connecting to the Internet in 1994 or 1995? Those of you do probably remember Trumpet Winsock. That ...

WinSock and more Open Source for your Windows Store apps
... platform commonality through universal Windows app... Today I want to follow up with some exciting news about the availability of WinSock and ...

David Treadwell - CrunchBase Profile
David Treadwell is corporate vice president of Microsoft’s Live Platform Services, a group that’s defining and implementing the next generation ...

Spyware - Wikipedia, the free encyclopedia
Spyware is a type of malware (malicious software) installed on computers that collects information about users without their knowledge. The presence ...

ActiveXperts Software - Product overview
Network Monitoring products and Windows Development components and tools by ActiveXperts Software

Weblib Database @ Alaska Software
... compatibility Version(1)Date(14.03.1900)Time(15:00:00)Size(93431)Needs(1.3.212)OS(W32)Format(ZIP)Language(Intl)Keywords(Socket, Internet, Winsock, ...

Freelancing tips - Binary Tides
... Adsense Database Freelancing Linux Programming Hacking Networking PHP Php Snippets Tutorial Socket Programming C Java Perl PHP Python Winsock ...

U-Mail邮件系统常见的退信分析 - U-MAIL邮件服务器资讯 - 比特博客
U-Mail邮件系统常见的退信分析看退信最下面的日志,并按照相应的错误信息进行匹配。511 sorry, no mailbox here by that nameunknown user account... User unknownName server r ..

CodeGuru - Microsoft developers related ideas, articles, tips, tricks, comments, downloads, and so much ...
CodeGuru is where developers can come to share ideas, articles, questions, answers, tips, tricks, comments, downloads, and so much more related ...

Resources last updated: 12/12/2015 7:02:58 AM