Ask Question Forum:
Model Library:2025-02-08 Updated:A.I. model is online for auto reply question page
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by duncanb7
at 2024-07-06 11:56:54
Point:500 Replies:17 POST_ID:828561USER_ID:11059
Topic:
Java Programming Language;PHP Scripting Language;JavaScript
Dear Expertts,
I am testing socket on php for tutorial at the php.net link,http://php.net/manual/en/sockets.examples.php
And want to ask why the IP address and port using
in the example is different between server.php and client.php code
From my concept, server need to create and bind its port and its server address
for clients access and sent out the server data. And Clients need to connect server's port and server's address and receive server data
I try it on my web remote server with IP address 203.217.29.100 and port 10000
for server.php and try the same IP and port for client.php. It works when I run client.php on my home PC xampp server which can recevie data from my remote server with IP address 203.217.29.100 and port 10000
I google a lot socket php example , they are using different port and address between server and client side. Suppose both sides should use same IP and port for communciation, Right ? Why they are using different
Please advise whether some concept or socket usage I 'm missing
Duncan
I am testing socket on php for tutorial at the php.net link,http://php.net/manual/en/sockets.examples.php
And want to ask why the IP address and port using
in the example is different between server.php and client.php code
From my concept, server need to create and bind its port and its server address
for clients access and sent out the server data. And Clients need to connect server's port and server's address and receive server data
I try it on my web remote server with IP address 203.217.29.100 and port 10000
for server.php and try the same IP and port for client.php. It works when I run client.php on my home PC xampp server which can recevie data from my remote server with IP address 203.217.29.100 and port 10000
I google a lot socket php example , they are using different port and address between server and client side. Suppose both sides should use same IP and port for communciation, Right ? Why they are using different
Please advise whether some concept or socket usage I 'm missing
Duncan
Author: duncanb7 replied at 2024-07-07 00:41:03
Thanks for your reply, it is clear
Duncan
Duncan
Accepted Solution
Expert: Dave Baldwin replied at 2024-07-06 14:47:09
167 points GOOD
No, NO Redirect.!!!! There is no redirect. It goes straight from serverIP:port 10000 to diskserverIP:port 6500. There isn't any intermediate step in the part that you do. Yes there is routing and a thousand details to make this work but none of the rest concerns you.
But yes, the different sources can go to the same destination. That is the way it always works. That is the way that you and I get this web site.
But yes, the different sources can go to the same destination. That is the way it always works. That is the way that you and I get this web site.
Author: duncanb7 replied at 2024-07-06 13:45:47
If agree previous post,
So it conclude it can use differernt address and port at server and client side but finally going to the same final end-point and same address and same port
Agree ?
Please advise
Duncan
So it conclude it can use differernt address and port at server and client side but finally going to the same final end-point and same address and same port
Agree ?
Please advise
Duncan
Author: duncanb7 replied at 2024-07-06 13:43:14
OR secenorio may be possilbe,
Server send data at port 10000 -->redirect->redirect-->disk server at port 6500
Client request data at port 8888--> redirect-redirect->disk server at port 6500
so they both server and client are at different address and ports
but go to same tagert destination, disk server at port 6500
So it conclude it can use differernt address and port but going to final end-point
Server send data at port 10000 -->redirect->redirect-->disk server at port 6500
Client request data at port 8888--> redirect-redirect->disk server at port 6500
so they both server and client are at different address and ports
but go to same tagert destination, disk server at port 6500
So it conclude it can use differernt address and port but going to final end-point
Author: duncanb7 replied at 2024-07-06 13:36:02
But final destination is same whatever your start point is or where
Expert: Dave Baldwin replied at 2024-07-06 13:14:11
You asked about needing the same port and the answer is that it does not have to be. It can be the same if you want and it works for you. It doesn't have anything to do with redirects. IP addresses are kind of like street addresses. The address gets you to the right building. The port number is like an apartment number, it tells where to go at that address. If you send a message from an apartment across town, both the apartment numbers and the street addresses are going to be different from each other.
There are many situations where the ports need to be different and are. One example is on a computer that has both a web server and a web browser. Communications to port 80 go to and from the web server software so a web browser must use different ports to communicate with web servers on other machines. The web browser Source port is Never port 80 although the Destination port for the web server always is.
There are many situations where the ports need to be different and are. One example is on a computer that has both a web server and a web browser. Communications to port 80 go to and from the web server software so a web browser must use different ports to communicate with web servers on other machines. The web browser Source port is Never port 80 although the Destination port for the web server always is.
Author: duncanb7 replied at 2024-07-06 13:04:08
Thanks, David, for your detail explained,
I mean whatever, we don't know the exact routing but the concept is
at the final end-point is same address and same port.
FOr example, I just know the number can contact you like 123456
but your exact phone number is 912912. I may be routed from 12345-->
234567->7899340--->your number,912912 by phone agent company ..
So you mean that, right ? but for internet, if they are both different address, one of them
is redirect address to rounte the same final end-point or final same address and ports
I mean whatever, we don't know the exact routing but the concept is
at the final end-point is same address and same port.
FOr example, I just know the number can contact you like 123456
but your exact phone number is 912912. I may be routed from 12345-->
234567->7899340--->your number,912912 by phone agent company ..
So you mean that, right ? but for internet, if they are both different address, one of them
is redirect address to rounte the same final end-point or final same address and ports
Expert: Dave Baldwin replied at 2024-07-06 12:53:31
It doesn't matter whether you are using a browser or not, TCP/IP and ports work the same way for all clients and servers. TCPView will show you all current connections of all kinds. It will help you understand what is going on.
Assisted Solution
Expert: Dave Baldwin replied at 2024-07-06 12:50:40
166 points GOOD
Re "the server only open socket at dedicated port and address and Client should use the same address and port to grab the server data", No that is not true or necessary. Client connects from their IP and port to the server's IP and port. All that info is set in the TCP headers so that the intermediate servers can use that to get the routing information to make the connection to the next point on the path.
TCPView is a GUI view of netstat that displays the TCP connections and refreshes every few seconds. It is much more useful when trying to see what your browser is doing.
And when you call me on the phone, my phone is used like the name of a web site to look up the actual routing required to make the connection. You do not know the actual routing path to get my phone to ring.
Though it is a little hard to read, this page seems to have all the info: http://www.citap.com/documents/tcp-ip/tcpip013.htm
TCPView is a GUI view of netstat that displays the TCP connections and refreshes every few seconds. It is much more useful when trying to see what your browser is doing.
And when you call me on the phone, my phone is used like the name of a web site to look up the actual routing required to make the connection. You do not know the actual routing path to get my phone to ring.
Though it is a little hard to read, this page seems to have all the info: http://www.citap.com/documents/tcp-ip/tcpip013.htm
Author: duncanb7 replied at 2024-07-06 12:42:29
Sorry, I am not talking about getting data from browser
I tried it successfully on the command line and window and linux shell
for both sides using the same address and ports
I tried it successfully on the command line and window and linux shell
for both sides using the same address and ports
Author: duncanb7 replied at 2024-07-06 12:34:49
Or client's address will redirect to server address and port at the final , so they can be both
are different like through a proxy
are different like through a proxy
Author: duncanb7 replied at 2024-07-06 12:28:34
tcpview , Is it similar to use netstat /? on window ? netstat also show your ISP address
and end-point address
and end-point address
Author: duncanb7 replied at 2024-07-06 12:25:33
When I ftp file I will use pspc.exe with the address and port provided by the server side
and , for example, when I call you, at least I know your exeact phone number
and , for example, when I call you, at least I know your exeact phone number
Author: duncanb7 replied at 2024-07-06 12:22:13
David, a little bit confusing, the server only open socket at dedicated port and address and
Client should use the same address and port to grab the server data, otherwise,
Client can set any address, if so Client can set www.yahooo.com address to grab experts-exhcange.com server data. Is it right? Please make it more undertandable for us.
Thanks
Client should use the same address and port to grab the server data, otherwise,
Client can set any address, if so Client can set www.yahooo.com address to grab experts-exhcange.com server data. Is it right? Please make it more undertandable for us.
Thanks
Author: duncanb7 replied at 2024-07-06 12:17:35
I want to know the concept first on php and then will be easier to apply it into java
since I'm not familar with Java code. SO I guess the concept is same for C, php, Java
using socket to send stream data.
since I'm not familar with Java code. SO I guess the concept is same for C, php, Java
using socket to send stream data.
Assisted Solution
Expert: Dave Baldwin replied at 2024-07-06 12:16:44
167 points GOOD
Re "both sides should use same IP and port for communciation", the answer is no, they don't need to and often don't.
If you get TCPView http://technet.microsoft.com/en-us/sysinternals/bb897437.aspx , you can see that your browser will use multiple ports for multiple windows and purposed to connect to the same port on the server. This is to make sure the data comes back to the correct window and process in the browser.
FTP uses multiple ports also.
If you get TCPView http://technet.microsoft.com/en-us/sysinternals/bb897437.aspx , you can see that your browser will use multiple ports for multiple windows and purposed to connect to the same port on the server. This is to make sure the data comes back to the correct window and process in the browser.
FTP uses multiple ports also.
Expert: CEHJ replied at 2024-07-06 12:03:28
Why is this q in the Java TA?