• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

socket creation doubt ?

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI,
I am trying to write a simple client server program, both the client and server program resides on the same local machine .
while creating a socket i dont know which port to mention
syntax
public Socket(InetAddress,int port)

How can i know which ports i can use .
i am working on my personal system so there is no question of admin problem
or restrictions
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use any port that's not currently in use. Most official services use ports below number 1024, so it's best to steer clear of those (and on UNIX, you can't use those without special privileges.) Pick a number above 2000 and if it works, then it's OK! Note that the important thing is that both client and server use the same number.
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After creating a socket, can it be used to send and receive data .
or is it each time i use it for sending or receiving i have to close the socket and create a new one?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sockets can be used for two-way communication (sending and receiving), and they do not need to be closed every time they send or receive something.
 
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



http://www.docdubya.com/belvedere/statement/browser.html

( ... an article written by Anish Shaikh ... )



[ Code here used by Nicholas Jordan in his project, thank you poster ! ]

[ Message edited 4:42 PM 9/21/2007: bias == (65535 - 46152) ]
[ September 23, 2007: Message edited by: Nicholas Jordan ]
 
And then the flying monkeys attacked. My only defense was this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic