Could not bind listening socket
RedHat 9
vsftpd running ok through xinetd verified that listening on port 21 On any client when ftp <servername> with any allowed user we get : "500 OOPS Could not bind listening socket" Tried all kind of searches with (usually responsive) Google but got nothing explaining/correcting. If it happened on the server i would understand, the daemon may not be able to start on port 21 if something else is on it etc.... but when trying to connect from another machine ??? Any ideas would be welcomed ! |
Hmmm, the only thing I can think of is that it's using Active Mode FTP by default, which uses port 20 for data. It might be trying to bind to port 20 locally, but if your daemon has dropped root privilages it won't be able to open a port < 1024. Have the clients try the "PASV" or "passive" command immediately after connecting. That *should* use a high port and ought to be able to bind OK.
|
error binding port
I have used this code but showing error binding port for all ports please help me with this
/* A simple server in the internet domain using TCP The port number is passed as an argument */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> void error(const char *msg) { perror(msg); exit(1); } int main(int argc, char *argv[]) { int sockfd, newsockfd, portno; socklen_t clilen; char buffer[256]; struct sockaddr_in serv_addr, cli_addr; int n; if (argc < 2) { fprintf(stderr,"ERROR, no port provided\n"); exit(1); } sockfd = socket(AF_INET, SOCK_STREAM, 0); if (sockfd < 0) error("ERROR opening socket"); bzero((char *) &serv_addr, sizeof(serv_addr)); portno = atoi(argv[1]); serv_addr.sin_family = AF_INET; serv_addr.sin_addr.s_addr = INADDR_ANY; serv_addr.sin_port = htons(portno); if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) error("ERROR on binding"); listen(sockfd,5); clilen = sizeof(cli_addr); newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen); if (newsockfd < 0) error("ERROR on accept"); bzero(buffer,256); n = read(newsockfd,buffer,255); if (n < 0) error("ERROR reading from socket"); printf("Here is the message: %s\n",buffer); n = write(newsockfd,"I got your message",18); if (n < 0) error("ERROR writing to socket"); close(newsockfd); close(sockfd); return 0; } |
I assume your test is a non-privileged user binding to a port >1024 as a daemon? Do you run selinux? If so, I believe you have to add a rule to bind to the port.
|
And just for the record, I hope you mean RHEL 9 and not RedHat 9.
As I recall RH9 went out of support in 2001 or 2002, while RHEL9 was just released in 2022. |
If you look at the date of the OP it is 2003. Post #3 is new and unrelated to the OP.
|
Quote:
|
Post #3. How about not posting a mess that no one can read.
BindPort.c Code:
#include <stdio.h> Code:
./BindPort 8100 Code:
./BindPort 8100 |
All times are GMT -5. The time now is 03:24 AM. |