Sponsored Content
Top Forums Programming C Prog to close a socket in established state Post 7911 by teledelux on Wednesday 3rd of October 2001 11:14:24 AM
Old 10-03-2001
C Prog to close a socket in established state

I have a SUN environment running an WebLogic that communicates w/a 3rd party running IIS. When the IIS site goes down (frequently), I am stuck with sockets in an ESTABLISHED state, and cannot seem to figure out how to avoid this. No exceptions are thrown as I can still open connections to the IIS site, but no data is returned.
What I would like to do is to determine from lsof -i tcp@host, the file descriptors, and then determine how long they have been in ESTABLISHED state, and then close them if they are older than say 1 hour.....

Any ideas????

As always- all help and assistance is greatly appreciated.
 

9 More Discussions You Might Find Interesting

1. HP-UX

socket close hangs and CPU go to 100%

Hello, I'm currently having a problem with HPUX. The application is a C app. It's a socket server. It runs mostly fine, but under some circumstances (I can not replicate it), the app hangs and the CPU goes to 100%. I have use gdb to attach to the app, and it was doing a close(). the... (0 Replies)
Discussion started by: arico
0 Replies

2. HP-UX

Close Socket at HP-UX

Hi all, I have a HP-UX 11.23 that have a Server establishing connections on port 8888 . The problem is that when i need to stop and restart the Server, the connections mantain the same state and i need to wait about 20-30 minutes before all connections finishes. The connections remain at... (2 Replies)
Discussion started by: Renato Gregio
2 Replies

3. UNIX and Linux Applications

any way to close socket

I have written a socker program. I have executed that program many times without closing the socket. So I want to find which all sockets binded with which file descriptor. Is there any way to close those socket, which have been opened in that program's execution. please help me!.. (3 Replies)
Discussion started by: pa.chidhambaram
3 Replies

4. Programming

socket close() -w- pthreads linux 2.6.18.2-34 (suse) SMP

Interesting issue. There was some discussion on the LKML last year regarding the potential problems in concurrent applications reusing file descriptors in various scenarios. The main issue is that the reuse of a file descriptor and reception of data in a threaded application can be confused pretty... (1 Reply)
Discussion started by: ramen_noodle
1 Replies

5. IP Networking

Is it necessary to close socket after a unstop loop?

Is the last two line necessary? #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> int main(void) { struct sockaddr_in stSockAddr; ... (0 Replies)
Discussion started by: vistastar
0 Replies

6. Solaris

socket in listen state disappears/closes automatically

Hi, I am using solaris 10. I have opened a socket connection using java in solaris 10 operating system, the port went to LISTEN state and able to create new socket connection and the new connections went to ESTABLISHED state. If I issue the command "netstat -an | grep <<portnumber>>", I... (10 Replies)
Discussion started by: kumar3k
10 Replies

7. Debian

Help socket prog

HI Can anyone provide me with codes for file transfer server to client or vice versa? Also please explain how to compile those programs in ubuntu terminal as i am totally new to socket programming. Thanks (0 Replies)
Discussion started by: mayhemtrigger
0 Replies

8. AIX

How to repair a TCP/IP socket in state: CLOSE_WAIT?

Hi The clients connect to my server -using port 9130. But no client could connect to my server at this time. I've checked already and this is the result netstat -Aan|grep -v 127.0.0.1|grep 9130|pg f10006000abcb398 tcp4 10313 0 10.0.89.81.9130 10.158.70.24.1705 CLOSE_WAIT... (8 Replies)
Discussion started by: bobochacha29
8 Replies

9. UNIX for Advanced & Expert Users

30 tcp connections Established for a while and after a few minutes are close

Good morning, I need your help please After Restarting Aps or connection, these are connections tcp 0 0 10.80.1.26.57597 10.81.248.79.53008 ESTABLISHED tcp 0 47 10.80.1.26.57607 10.81.248.79.53008 ESTABLISHED tcp 0 0 ... (4 Replies)
Discussion started by: alexcol
4 Replies
FILE(3) 								 1								   FILE(3)

file - Reads entire file into an array

SYNOPSIS
array file (string $filename, [int $flags], [resource $context]) DESCRIPTION
Reads an entire file into an array. Note You can use file_get_contents(3) to return the contents of a file as a string. PARAMETERS
o $filename - Path to the file. Tip A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen(3) for more details on how to specify the filename. See the "Supported Protocols and Wrappers" for links to information about what abilities the various wrappers have, notes on their usage, and information on any predefined variables they may provide. o $flags - The optional parameter $flags can be one, or more, of the following constants: o FILE_USE_INCLUDE_PATH - Search for the file in the include_path. o FILE_IGNORE_NEW_LINES - Do not add newline at the end of each array element o FILE_SKIP_EMPTY_LINES - Skip empty lines o $context - A context resource created with the stream_context_create(3) function. Note Context support was added with PHP 5.0.0. For a description of contexts, refer to "Streams". RETURN VALUES
Returns the file in an array. Each element of the array corresponds to a line in the file, with the newline still attached. Upon failure, file(3) returns FALSE. Note Each line in the resulting array will include the line ending, unless FILE_IGNORE_NEW_LINES is used, so you still need to use rtrim(3) if you do not want the line ending present. Note If PHP is not properly recognizing the line endings when reading files either on or created by a Macintosh computer, enabling the auto_detect_line_endings run-time configuration option may help resolve the problem. CHANGELOG
+--------+----------------------------+ |Version | | | | | | | Description | | | | +--------+----------------------------+ | 4.3.0 | | | | | | | file(3) became binary safe | | | | +--------+----------------------------+ EXAMPLES
Example #1 file(3) example <?php // Get a file into an array. In this example we'll go through HTTP to get // the HTML source of a URL. $lines = file('http://www.example.com/'); // Loop through our array, show HTML source as HTML source; and line numbers too. foreach ($lines as $line_num => $line) { echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br /> "; } // Another example, let's get a web page into a string. See also file_get_contents(). $html = implode('', file('http://www.example.com/')); // Using the optional flags parameter since PHP 5 $trimmed = file('somefile.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); ?> NOTES
Warning When using SSL, Microsoft IIS will violate the protocol by closing the connection without sending a close_notify indicator. PHP will report this as "SSL: Fatal Protocol Error" when you reach the end of the data. To work around this, the value of error_reporting should be lowered to a level that does not include warnings. PHP can detect buggy IIS server software when you open the stream using the https:// wrapper and will suppress the warning. When using fsockopen(3) to create an ssl:// socket, the developer is responsible for detecting and suppressing this warning. SEE ALSO
readfile(3), fopen(3), fsockopen(3), popen(3), file_get_contents(3), include(3), stream_context_create(3). PHP Documentation Group FILE(3)
All times are GMT -4. The time now is 11:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy