*
The moose likes Sockets and Internet Protocols and the fly likes Socket/TCPIP help required Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Socket/TCPIP help required" Watch "Socket/TCPIP help required" New topic
Author

Socket/TCPIP help required

Tiger Scott
Ranch Hand

Joined: Mar 01, 2001
Posts: 223
Hi,
I have to open a socket connection to a server using the providers documentation. Can somebody help translate it in Java for me. This is what the documentaion has:
fd=socket(AF_INET,SOCK_STREAM,TCP_PROTO)
myaddr=(socket structure){AF_INET,wsport,myIPAddr)
bind(fd,myaddr)
apiaddr=(socketaddr structure){AF_INET,SERVER_PORT,serverIPaddr)
connect(fd,apiaddr)
AF_INET=2, SOCK_STREAM=2,TCP_PROTO=6
wsport= a unique client port
myIPAddr= client IPAddr
SERVER_PORT,serverIPaddr- known
fd- definition of socket connection
Thanks a lot,
Sanjay
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
To me it looks like this is just opening a TCP socket connection to the server -- i.e. you can simply instantiate a java.net.Socket, get the input- and/or output stream and off you go.
- Peter
Tiger Scott
Ranch Hand

Joined: Mar 01, 2001
Posts: 223
Peter,
Thanks.
You mean just open a Socket with:
Socket(String host, int port, InetAddress localAddr, int localPort)
Sanjay
Mirza Galib
Greenhorn

Joined: Jun 02, 2002
Posts: 12
open a socket with:
Socket soc = new Socket("200.200.200.200",3333) ;
///////////
get the stream

Input Stream = soc.getInputStream());
////////
There is also a catch in it
they are also asking to bind it
They could also be talking about a ServerSocket
Syntax for it is
ServerSocket ser = new ServerSocket(3333);
Socket soc = ser.accept();

Accept method will return the value of incoming socket in the form of socket.


"Hain aur bhee duniya mein sukhanwar bahut acche.<br />Kehte hein ke Galib ka hai andaz-e-bayaan aur."
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Socket/TCPIP help required
 
Similar Threads
Dynamic IP address and socket programming.
Java Server, PHP client
How to transport 2 dimension array of integer using byte array.
Check Socket Connection State
ServerSocket not oppening