Can we send a tcp/ip message from a specific port to the client

Hi All,
Iam currently trying to send a tcp/ip message to a remote machine on a specific destination port. For each tcp/ip message that iam sending iam able to figure out that the source port varies each time. So I wanted to know if it is possible to maintain a source
port for sending a tcp/ip message just like a destination Port. You can see my code below for reference:
 TcpClient client = new TcpClient();          
            client.Connect("xxx.xxx.xx.xx", 2024);
            NetworkStream clientStream = client.GetStream();
            ulong refno = GetSessionID();
            DateTime dt = DateTime.Now;
            string str = dt.Year.ToString() + "-" + dt.Month.ToString() + "-" + dt.Day.ToString() + " " + dt.Hour.ToString() + ":" + dt.Minute.ToString() +
":00";
            ASCIIEncoding encoder = new ASCIIEncoding();
            string Input2 = "<STX>Inquire<US>REF=203.163.253.55<US>RQN=" + refno.ToString() + "<US>DTE=" + str + "<US>ACI=5274<US>ACE=C<US>ACS=A<ETX>";
            string Input3 = "<STX>Inquire<US>REF=203.163.253.55<US>RQN=" + refno.ToString() + "<US>DTE=" + str + "<US>ACI=5274<US>ACE=C<US>ACS=A<ETX><CHECKSUM>";
            int length = Input2.Length;
            string hexValue = Input2.Length.ToString("X");
            string hexValue2 = length.ToString("X");
         //   string Input = "\x02 Inquire\x1F REF=203.163.253.55\x1F RQN=" + refno.ToString() + "\x1F DTE=" + str + "\x1F ACI=5274\x1F ACE=C\x1F ACS=A\x1F \x3 \\x" + hexValue2;
            string Input = "02Inquire1FREF=203.163.253.551FRQN=" + refno.ToString() + "1FDTE=" + str + "1FACI=52741FACE=C1FACS=A1F3" + hexValue2;
            byte[] buffer = encoder.GetBytes(Input);
            clientStream.Write(buffer, 0, buffer.Length);
            clientStream.Flush();
ram

Hi ram,
The TcpClient class has a constructor that receives an IPEndPoint instance, this is the local EndPoint.
The IPEndPoint consists of two parts, the IP address and the port to use. you can specify the local port with this parameter.
IPAddress ipAddress = Dns.GetHostEntry (Dns.GetHostName ()).AddressList[0];
int port=9999;
IPEndPoint ipLocalEndPoint = new IPEndPoint(ipAddress, port);
TcpClient tcpClientA = new TcpClient (ipLocalEndPoint);
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • I can't send or receive text messages from non iphone users

    I can't send or receive text messages from non iphone users

    Under Settings - Messages, do it state Sens SMS ON? Should be (this applies to imessage but just in case).
    Same area, MMS Messaging is on? Should be.
    If all else fails, go into Settings General Reset - Reset Network Settings (this will lose WiFi info but fixes a lot of messaging errors).

  • I can neither send nor reply to messages from my iPhone 4.  It may be since I downloaded iOS 6.0 but not sure.

    I can neither send nor reply to messages from my iPhone 4.  It may be since I downloaded iOS 6.0 but not sure.  Any suggestions?

    No, sorry, I meant emails.  I can no longer compose emails or reply to emails on my iPhone -- only receive them.  Any idea why?  Thank you!

  • Can you send a text (sms) message from a web site form ?

    Anyone know of a reliable script or app that will allow a site visitor to fill out a 'form' and send an instant text message from the site ?  Same as email...but rather than email...type out and send a text message instead ?
    Thanks, Tim

    Tecnically yes. This is because SMS is basically handled just like an email address, ie; [email protected]
    There are services out there that will charge you either flat rate or per message to send them for you as you would need to know what server that number is on. If you want to have people select what carrier that number is on, you just create a mail form with a dropdown with a list of carriers that then set the domain variable in the TO address field. You have to plan that the user doesn't know what carrier that phone number is on, thus where the pay-for sites come in handy.

  • How can I send and receive a message from  a queue using standalone program

    Hi,
    I want to write a standalone Java program which has to post a message to a queue and receive a message from a queue thats specified as a replyto queue.I want to have my application to be completely standalone without the need of a Application server.What all the Jars do I need to include in the application.My aim is to have the application standalone and portable so that the application runs on any machine that has a JRE.
    Thanks in advance,
    Prathima

    Hi,
    You can get quite simple standalone MQ Java programs from this site http://www.capitalware.biz/mq_code_java.html.
    Also regarding the jars required for your application depends on the API being used. If you use MQI API few jars are required and if you decide to use JMS API you'll require few other jars. But you got to either install Websphere MQ Java Client, which will copy the jars to the respective location, or you can choose to copy the jars from some other machine manually.
    Eventually, all the jars related to MQI and JMS API will reside under /usr/mqm/java/lib/ or /var/mqm/java/lib/ UNIX Environment. And in case of WINTEL, you should find the jars under C:\Program Files\IBM\WebSphere MQ\Java\lib.
    Trust it clarifies...
    Naren

  • HT1349 Can't send email...message says email was rejected by the server because it does not allo relaying

    Can't send email because message says email was rejected by the server because it does mot allow relaying?  What to do?

    Go into your SMTP outgoing mail server and enter your username and password.

  • Need to send a 403 (forbidden) message from proxy to client

    I have create a List that contains URL's that I want to block from the user. Once I search that list and see that the requested URL is in the list, I need to send a 403(forbidden) message. Does anyone know if I can just send a "HTTP/1.0 403 Forbidden" Header back to the client in bytes from my DataOutputStream object??
    Anyone have any other suggestions I would appreciate it.

    You can get all you need from the HTTP 1.1 specification. i.e. http://www.w3.org/Protocols/rfc2616/rfc2616.txt

  • Exchange I can recieve messages, but can not send, reply, or update calendar from Pre.

    Exchange  I can recieve messages, but can not send, reply, or update calendar from Pre.
    This worked on Version 1.0 but does not work on 1.3.  Is there anyway to go back to ver. 1.0
    Post relates to: Pre p100eww (Sprint)

    Text messages as in SMS/MMS, or iMessages?
    If the former, contact your carrier.

  • On previous iPhones you could go to settings and block the the actual text message from pooping up. Only the sender would show up. On the i4gs the sender and message show up. This is a major flaw as far as privacy. There are no options with in settings to

    On previous iPhones you could go to settings and block the the actual text message from pooping up. Only the sender would show up. On the i4gs the sender and message show up. This is a major flaw as far as privacy. There are no options with in settings to stop this from happening. PLEASE TELL ME IM WRONG ???

    YOU ARE WRONG.
    Go to Settings > Notifications > Messages. You can turn Notifcation Center off for Messages, or select None for the alert style, and turn Show Preview off, and view in Lock Screen on or off.

  • Mail with multiple gmail accounts sending messages from wrong email, other than the one i select

    mail with multiple gmail accounts sending messages from wrong email, other than the one i select:
    i'm using mail on osx 10.7 with multiple gmail accounts. when i create an email, i check to be sure i'm sending/replying from the correct account. after i send it, somehow it actually sends it from a different account, other than the one i've selected "from." this is evidenced by the reply email i receive. how can i fix this?
    in preferences, i have "send new messages from : account of selected mailbox"

    From the Mail menu bar, select
              Mail ▹ Preferences...
    The Mail preference dialog opens. Select the Composing tab from the row of icons at the top. From the menu labeled
              Send new messages from:
    choose
              Account of selected mailbox
    Note that this setting may have no effect if you start a new message while a VIP or smart mailbox is selected in the mailbox list. Those are saved searches, not actual mailboxes.
    If the problem remains, select the Accounts tab in the preference dialog, then select the affected account in the list on the left.
    In the Account Information pane, select the correct server in the menu labeled
              Outgoing Mail Server (SMTP)
    If there's only one server in the menu, select
              Edit SMTP Server List...
    and add a new server with the correct settings. If you're not sure how to do that, try the Mail Settings Lookup.
    Another possibility is that the wrong card in your address book is selected as yours. Select your card in the Contacts application. Then select
              Card ▹ Make This My Card
    from the menu bar.

  • Can u send an URGENT text message on the Droid Charge???

    I been trying to figure out how to send an urgent text message. I've had the phone since lst November and seems all I can do is send regualr text messages. How can u send an urgent text message so that it grabs the recipients attention to respond as soon as possible. Like for example, that person ur sending the message to is in a situation where they cant recieve phone calls, so u gotta text them instead and its an urgent matter, so ur wanna to send an urgent text message that grabd their attention immediately.  So does anyone know how u go about sending an urgent text message? Please get back to me. Thanks -Brian

    don't know aside from calling someone.  if they are unable to receive phone calls, then they are probably unable to receive texts.  you could sending them an e-mail - perhaps they have a data signal?

  • Can I send already sent text messages to my computer to print them?

    Can I send already sent text messages to my computer to print them?

    The only way I know of to save a Text message for printing is to copy it to your memo's and then print it out through the desktop software. Unfortunately there is no way to save a text message on the desktop otherwise and there is no way to print directly from the text message software. You can store them in the "saved" folder if you want as well, but that won't copy them to the desktop or allow them to print.
    Post relates to: Centro (AT&T)

  • I can't send photos through iChat/Messages?

    Hello! I have a MacBook Pro and I can't seem to send photos through iChat to my friends. I am able to receive photos, though. I can drag a photo into the message box and I can click send and it looks as if I've successfully sent the photo. However, after a few seconds, the message bubble becomes blank and a picture is no longer there and my friend tells me she can't see anything. I've updated to Mountain Lion but I still can't send photos through Messages. Does anyone have any idea why? Thank you in advance!

    Hi,
    The Messages app in Mountain Lion is a fusion of iChat (which uses AIM Screen Names and Jabber IDs to create Buddy Lists) and iMessages from the iOS side of things.
    iMessages can be sent if you register your Apple ID for iMessages when opening Messages for the first time.
    The same Apple ID is then used on your iOS devices (iPads, iPhones and some iPod Touch devices) so that you can sync the conversations you are having.
    iChat is /was an app in Lion and earlier Mac OS version that could join the AIM or Jabber Service (And the Yahoo service in iChat 6 in Lion).
    In those versions Buddy List were displayed by default.
    In Messages the default is to display any Non iMessage Accounts (Seen in Messages Menu > Preferences > Accounts.) as one list, which can be brought to the front by the Keystrokes CMD + 1 keys together (See Window Menu)
    You can separate the Buddy lists by going to Message Menu > Preferences > General section and unticking the items that say about gathering accounts into one list.
    Uploaded with Skitch!
    This changes the Window Menu to then list all the Buddy lists, each with their own CMD + #
    Uploaded with Skitch!
    As you can see I have an Account callled Google talk (And another that logs in to Jabber.me)
    The Names shown here are what you enter in to the Description field in Messages menu > Preferences > Accounts.
    If you enter nothing and have one account that logs in to AIM and another that logs in to Google the Account Buddy List window will get titled "AIM Buddy List" and Jabber Buddy List as Google run a Jabber server.
    If you have more, like I do, of both sorts then they take on the Screen Name or ID of the account if you don't fill in the Description field.
    (The Partially Blocked out one is doing this as it is an AIM registered Name)
    If your Apple ID happens to be your Google Mail ID and you have set it up for iMessages it also needs setting up for the "iChat" Google Talk side  (it may be already there if updating from Lion)
    However you cannot send iMessages to your Google Buddies or vice versa - sending IMs from your Google Buddy list to Contact's Apple IDs
    So make sure the Messages window is saying you are using iMessages if talking to Contacts or your IM account type (or name/ID) if using Buddy lists.
    If your Apple ID can also be used with the AIM or Jabber services then double check what you have set up in Messages > Preferences > Accounts and which you ware using.
    7:23 PM      Sunday; August 26, 2012
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"
      iMac 2.5Ghz 5i 2011 (Lion 10.7.2)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • Why am I  no longer able to send or receive text messages from my Droid RAZR MAXX HD?

    Why am I no longer able to send or receive text messages from my Droid RAZR MAXX HD? 

        @slotjan49
    I want to ensure you're able to stay connected using your Motorola Droid Razr Maxx HD!  When did this problem begin?  In what zip code are you experiencing this?  Do you get an error message when attempting to send a text?  Are you using a downloaded text messaging application or are you using the preinstalled text messaging application?
    Please try removing and reinserting the SIM Card http://vz.to/1jxFQVZ and retesting.  Please let me know so that I can further assist.  Thanks!
    AnthonyTa_VZW
    Follow us on Twitter @VZWSupport

  • Can't send OVI IMAP e-mails from mobile phone or o...

    Since a few weeks, I can't send OVI e-mails (IMAP) from my Nokia mobile phone, or Outlook express. Receiving e-mails works fine. So, I can only work using the webmail interface.
    - Settings I am using on Outlook express:
    Incoming email:
    User name: [email protected]
    Password: *****
    Incoming mail server: imap.mail.ovi.com
    Mailbox type: IMAP 4
    Security (ports) SSL/TLS
    Port: Default
    Outgoing email:
    My email address: [email protected]
    User name: [email protected]
    Password: *****
    Outgoing mail server: smtp.mail.ovi.com
    Security (ports): SSL/TLS
    Port: Default
    - Settings I am using on my mobile phone:
    imap.mail.ovi.com
    smtp.mail.ovi.com
    IMAP 4
    SSL/TLS: 993
    SSL/TLS: 465
    If you have experience with this issue, thank you in advance for sharing your knowledege.

    Hi Mitch_2012,
    Thank you for your post and welcome to the forums!
    We would advise you try the following SMTP server on your Outlook Express:
    ovi.smtp.mail.yahoo.com, SSL port 465
    When entering your username, please be sure to include your complete @ovi.com email address (For example [email protected]).
    You did not mention your phone model in your message. So, try to reset your phone to factory settings by following the instructions in your phone's user guide. This will clear all settings and mailboxes on your device, after that just set up your OVI mailbox again by following these instructions. 
    Let us know if this helps,
    Puigchild
    If you find this post helpful, a click upon the white star at bottom would always be appreciated.
    If it also solves your problem, clicking ACCEPT AS SOLUTION below it will benefit other users!

Maybe you are looking for

  • Cascading List of Values does not work when SQLBuilder is SQL 92.

    Hi, I followed the link http://download.oracle.com/otn_hosted_doc/jdeveloper/11/demos/ADFBC_Cascading_LOV/ADFBC_Cascading_LOV.html to create Cascading LOV. The LOV comes up fine when sqlbuilder and type map is specified as Oracle. However, the same f

  • Can't get email to work

    Keeps saying wrong user id or password.   Have tried several nothing works. AT&T said Yahoo server down today causing problem.  My friends all using theirs.

  • UDF in XlL reporter

    Hi all! I can't show UDF in XL reporter composer when i checked visible in Tool/ User deine fields of XL reporter program. Why?? Can you help me Thank you!

  • Order Book

    When I click "Buy Now" then appear text "Unable to Assemble Book * -[NSPlaceholderMutableString initWithString:]: nil argument" Can somebody explain me what is wrong? How can I buy a book?

  • Best Practice Buttons? and Swing Button Sizes

    Hi, I am wondering what the best way to make a custom styled button was.... Since I need my own style of button (width,height,background image, selected, clicked) I thought I would use Swing buttons with a Synth style. However, when I place swing but