Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9069477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:26:20+00:00 2026-06-16T17:26:20+00:00

We have web application , it works as Socket Listner. I wanted to check

  • 0

We have web application , it works as Socket Listner. I wanted to check before the AcceptSocket , whether there is any Client Socket available to connect to this listner. I want to display a message if there is no Client Socket to connect and cancel send/receive of data.

I am using TCPListner using ASP.net C# for the web application. The Client socket is windows VB6 application using Winsock control.

Socketing programme, ASP.Net C#, VS2008

Thanks you for the reply ,

see below my sample code for communicate with server

clsCommunication.cs, this class file imports into .aspx page. I tried using Console.WriteLine(), but cann’t shown this message.

I wanted to display alert box , so that user understands there is no connection OR display on status bar or highlight a frame/box etc.

public void Communicationcation()
{
    byte[] bytes = new byte[1024];
    string strSiteID = "SiteID";

    socket.Start();
    if (!socket.Pending())
    {
        Console.WriteLine("Sorry, no connection requests have arrived");
    }
    else
    {
        client = socket.AcceptSocket();
        if (client.Connected == true)
        {
            decimal dSiteID = decimal.Parse(GetSiteSetting(ref strSiteID).ToString());
            IPEndPoint clientep = (IPEndPoint)client.RemoteEndPoint;

            WriteLog(string.Format("Connected with {0} at port {1}",  clientep.Address,  clientep.Port));
            string strWelcome = STARTMESSAGE + "WHOAMI" + "     " + dSiteID + " " + dSiteID + FINISHMESSAGE;
            byte[] data = new byte[1024];
            data = Encoding.ASCII.GetBytes(strWelcome);
            int i = client.Send(data, data.Length, SocketFlags.None);
            WriteLog(String.Format("Message sent {0} bytes!", i));

            //Get reply from the Connected cleint.
            i = client.Receive(bytes, bytes.Length, SocketFlags.None);
            if (i != -1)
            {
                WriteLog(string.Format(System.Text.Encoding.UTF8.GetString(bytes)));
            }
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T17:26:22+00:00Added an answer on June 16, 2026 at 5:26 pm

    You can use TcpListener‘s Pending method, see http://msdn.microsoft.com/en-us/library/system.net.sockets.tcplistener.pending.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application that works in our stage/test environment fine but once
I have a web application project that works with a quite large database (over
I have an ASP.NET 3.5 web application which works perfectly fine on my local
I have developed a web application using Netbeans 6.7 and Ant. The webapp works,
I have an Asp.Net MVC application that works in the vs.net development web server.
I have developed a web based application which allows a client/user to upload a
In my Windows 8 JS application, I have a web socket object defined like
I have written an application that connects to a SSL web service (including client
I have a Java web application at my work and I'd like simplify how
We have a web application talking to a Postgres SQL database at work -

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.