Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. HttpWebRequest/Response in a Duplex way?

HttpWebRequest/Response in a Duplex way?

Scheduled Pinned Locked Moved C#
sysadminhelpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    softwarejaeger
    wrote on last edited by
    #1

    Hello, i want to communicate between a client/server application with HttpWebRequest an HttpWebResponse. My problem is, that i have a server farm. I want to have sessions and want to be able to send and receive informations. The problem is now, that i can't really work like a web-Server. A request and i deliver a response. I need to talk on one connection in a duplex way. So is it possible to create a HttpWebRequest and to send informations in it, receive some informations and use the same Request(Connection) for sending another Informations? Thank you

    A T 2 Replies Last reply
    0
    • S softwarejaeger

      Hello, i want to communicate between a client/server application with HttpWebRequest an HttpWebResponse. My problem is, that i have a server farm. I want to have sessions and want to be able to send and receive informations. The problem is now, that i can't really work like a web-Server. A request and i deliver a response. I need to talk on one connection in a duplex way. So is it possible to create a HttpWebRequest and to send informations in it, receive some informations and use the same Request(Connection) for sending another Informations? Thank you

      A Offline
      A Offline
      Adam R Harris
      wrote on last edited by
      #2

      Hello SoftwareJaeger, The short answer is NO, HttpWebRequest/Response is just that a single request and response. You can constantly open, close and re-use them all you like but you are not going to get the bi-directional (or duplex) communication you are looking for. What you need is to actually open TCP or UDP sockets and then send all your calls from there. Really a very basic example would be a chat client (i.e. Windows Live Messenger) which implements the type of functionality you want. There is a great little article here on CP that will walk you through creating a chat client with UDP sockets here[^] that will illustrate the principals of what it is that you need to do.

      Don't comment your code - it was hard to write, it should be hard to read!

      1 Reply Last reply
      0
      • S softwarejaeger

        Hello, i want to communicate between a client/server application with HttpWebRequest an HttpWebResponse. My problem is, that i have a server farm. I want to have sessions and want to be able to send and receive informations. The problem is now, that i can't really work like a web-Server. A request and i deliver a response. I need to talk on one connection in a duplex way. So is it possible to create a HttpWebRequest and to send informations in it, receive some informations and use the same Request(Connection) for sending another Informations? Thank you

        T Offline
        T Offline
        TheyCallMeMrJames
        wrote on last edited by
        #3

        A little back story to Adam's response: HTTP is a stateless protocol. You fire, and you're not necessarily guaranteed a response. In some web farms sessions are maintained across servers, but in others, the sessions are load balanced. You should be able to rely on session data, but it is still not proper stateful communication. The client makes a request (breaking it down, even, in multi-part scenarios). The server fulfills the request (by returning a status code and possibly payload). That is the end of com. As Adam suggested, you'll need to drop to a different protocol/level to achieve what you're looking for and maintain the open connection. Cheers.

        They Call me Mister James

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups