LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Closed Thread
  Search this Thread
Old 06-23-2005, 01:03 PM   #1
mrobertson
Member
 
Registered: May 2005
Posts: 275

Rep: Reputation: 30
source code for a php3 server


Does anyone have any source code avaiable for a php3 server that would be comprable to this socket coding done in php5?


Code:

if (($sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) < 0) {
		echo "socket_create() failed. Reason: " . socket_strerror($sock) . "<BR>";
	}

	if (($ret = socket_bind($sock, $address, $port)) < 0) {
		echo "socket_bind() failed. Reason: " . socket_strerror($ret) . "<BR>";
	}

	//Start listening on the socket
	if (($ret = socket_listen($sock, 5)) < 0) {
		echo "socket_listen() failed. Reason: " . socket_strerror($ret) . "<BR>";
	}

	//Accept an incoming connection
	if(($client = socket_accept($sock)) < 0) {
		echo "socket_accept() failed. Reason: " . socket_strerror($ret) . "<BR>";
		break;
	}

	//Read whatever was just sent, 1024 bytes' worth. Make this however long you need.
	if( false == ($global_string = socket_read($client, 2048))) {
		echo "socket_read() failed. Reason: " . socket_strerror($ret) . "<BR>";
		break;
	}
 
Old 06-24-2005, 09:49 AM   #2
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
Please do not post the same question in the forums more than once.

http://www.linuxquestions.org/questi...hreadid=336405

Closing thread.
 
  


Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Source Code for a simple ftp server and client koodoo Programming 17 07-05-2013 11:48 AM
How to convert Assembly code to "C" source code ssg14j Programming 2 08-01-2005 12:48 PM
Apache source code hack - Server response headers 2.0.49 fireman949 Linux - Software 2 05-24-2004 10:31 AM
source code vishal_iet Linux - General 5 12-26-2002 11:37 AM
Looking for source code sourceman Linux - General 0 05-21-2002 01:58 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:56 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration