# XMLSocket.send() to Java

**URL:** <https://forum.kirupa.com/t/xmlsocket-send-to-java/185943>\
**Category:** programming\
**Created:** [April 17, 2006, 10:59pm UTC](https://forum.kirupa.com/t/xmlsocket-send-to-java/185943 "2006-04-17T22:59:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![OMG](https://avatars.discourse-cdn.com/v4/letter/o/9dc877/32.png) [@OMG](https://forum.kirupa.com/u/OMG)\
**Post date:** [April 17, 2006, 10:59pm UTC](https://forum.kirupa.com/t/xmlsocket-send-to-java/185943/1 "2006-04-17T22:59:06Z")

</div>

hi I have a question about this:  
I use XMLSocket.send() to send things to Java. But if there’s 2 java programs in the same folder, how do I know to which one I want to send the message? There’s no option for this, unlike when I send informations to a server-side language, like this:  
loadVariables(“myPHP.php”, “POST”)  
what I’m saying is I can’t do this:  
XMLSocket.send(“myApp.java”, myXML)

---

<div class="post-metadata">

**Author:** ![mathew\_er](https://avatars.discourse-cdn.com/v4/letter/m/94ad74/32.png) [@mathew\_er](https://forum.kirupa.com/u/mathew_er)\
**Post date:** [April 18, 2006, 12:50am UTC](https://forum.kirupa.com/t/xmlsocket-send-to-java/185943/2 "2006-04-18T00:50:37Z")

</div>

Cant you make them listen on different ports?

---

<div class="post-metadata">

**Author:** ![OMG](https://avatars.discourse-cdn.com/v4/letter/o/9dc877/32.png) [@OMG](https://forum.kirupa.com/u/OMG)\
**Post date:** [April 18, 2006, 1:37am UTC](https://forum.kirupa.com/t/xmlsocket-send-to-java/185943/3 "2006-04-18T01:37:17Z")

</div>

what do you mean?

---

<div class="post-metadata">

**Author:** ![mathew\_er](https://avatars.discourse-cdn.com/v4/letter/m/94ad74/32.png) [@mathew\_er](https://forum.kirupa.com/u/mathew_er)\
**Post date:** [April 18, 2006, 7:40am UTC](https://forum.kirupa.com/t/xmlsocket-send-to-java/185943/4 "2006-04-18T07:40:11Z")

</div>

When you are connecting to some socket server with XMLSocket.connect(), you specify a port on which you want to make connection and that application you are trying to connect to has to listen on that port… so  
mySocket.connect(“localhost”, 2000) and  
mySocket.connect(“localhost”, 3000)  
could be two different applications…

---

<div class="post-metadata">

**Author:** ![OMG](https://avatars.discourse-cdn.com/v4/letter/o/9dc877/32.png) [@OMG](https://forum.kirupa.com/u/OMG)\
**Post date:** [April 18, 2006, 8:41pm UTC](https://forum.kirupa.com/t/xmlsocket-send-to-java/185943/5 "2006-04-18T20:41:42Z")

</div>

thanks. But how do I set the .java file’s port so it can receive the right one?

---

<div class="post-metadata">

**Author:** ![mathew\_er](https://avatars.discourse-cdn.com/v4/letter/m/94ad74/32.png) [@mathew\_er](https://forum.kirupa.com/u/mathew_er)\
**Post date:** [April 18, 2006, 10:31pm UTC](https://forum.kirupa.com/t/xmlsocket-send-to-java/185943/6 "2006-04-18T22:31:37Z")

</div>

You can modify it’s main function so you could choose a port when you launch the class file or change it pemanently in the source… look for a line with “new ServerSocket(portNumber);”

---

<div class="post-metadata">

**Author:** ![OMG](https://avatars.discourse-cdn.com/v4/letter/o/9dc877/32.png) [@OMG](https://forum.kirupa.com/u/OMG)\
**Post date:** [April 19, 2006, 11:59pm UTC](https://forum.kirupa.com/t/xmlsocket-send-to-java/185943/7 "2006-04-19T23:59:36Z")

</div>

thanks!
