Bad value on output port 'tcp_inet'

Jeff Crane jefcrane@REDACTED
Sun Aug 13 22:29:23 CEST 2006

I know this must come up a lot, but I have no idea how
I am messing this client up. I connect to a remote
scheme listener, but I cant seem to read back the
responses. Although the scheme listener catches it, I
am getting {error,einval} (from the listener? from the
program? from the socket?) and cannot read anything. 

The listener is a simple echo server.


%% methods include
%% usage
%% benign_client:test("",41)
start(Host,Port) ->
    spawn(fun() -> test1(Host,Port) end).

%% send a single message to the server wait for
%% a reply and close the socket

test1(Host,Port) ->
	case gen_tcp:connect(Host, Port, [binary,{packet,
0}]) of
		{ok, Socket} ->
			%% let me know about the socket
			%% send a string with newline
			gen_tcp:send(Socket,io:format("hello joe~n")),
			%% read reply
			%% I'm done.
		Any ->
			io:format("Error = ~p~n",[Any]),

do_recv(Socket) ->
    case gen_tcp:recv(Socket, 0) of
        {ok, B} ->
            io:format("reply tuple:~p~n",[B]);
	X -> 
	    io:format("reply atom:~p~n",[X])
%%    	wait_reply(X) ->
%% 	    receive
%% 	        X ->
%% 	            {value, X}
%% 	    after 100000 ->
%% 	            timeout
%% 	    end.

Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

More information about the erlang-questions mailing list