Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7732843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:49:59+00:00 2026-06-01T06:49:59+00:00

I am trying to send data from PHP Client to Python Server. CLIENT <?php

  • 0

I am trying to send data from PHP Client to Python Server.

CLIENT

<?php

$host = "127.0.0.1";
$port = 2000;

$output="datatatatatatta" ;

$socket1 = socket_create(AF_INET, SOCK_STREAM,0) or die("Could not create socket\n");

socket_connect ($socket1 , $host,$port ) ;

socket_write($socket1, $output, strlen ($output)) or die("Could not write output\n");

socket_close($socket1) ;


?>

SERVER

import socket
import sys
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)

host= 'VAC01.VACLab.com'
port=int(2000)
s.bind((host,port))
s.listen(1)

conn,addr =s.accept()

print (conn,addr)

data=conn.recv(100000)
data=data.decode("utf-8")

s.close


FILE = open("c:/vinod/vin.txt","w")
FILE.write(str(data))
FILE.close()

On the client side I get the following error ,.

Warning: socket_connect() [function.socket-connect]: unable to connect [0]: No connection could be made because the target machine actively refused it. in C:\xampp\htdocs\xampp\socket.php on line 10

Warning: socket_write() [function.socket-write]: unable to write to socket [0]: A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied. in C:\xampp\htdocs\xampp\socket.php on line 12
Could not write output 

Is this possible to connect this way ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T06:50:00+00:00Added an answer on June 1, 2026 at 6:50 am

    You bind to a host that most likely does not resolve to 127.0.0.1 but connect to 127.0.0.1. That cannot work. You have two options:

    1. Use 127.0.0.1 (or localhost) on both sides
    2. Use the hostname VAC01.VACLab.com on both sides
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to send data from an Android app to a PHP file
I am trying to send the POST data from java to a PHP page.
i couldn't send data from my device to my php file. i am trying
I am trying to send data from dynamicly generated cheboxes(when ticked) to my php
I am trying to send data from PHP to a bash script and then
I have been trying to send xml message from php to asp and output
I'm trying to send a sms using php from my ftp server in the
I am trying to send data from an activity to service via intents. This
I am currently trying to send some data from and Android application to a
I'm trying to send data to the Controller from the View. I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.