Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

Revision 97a6960daa89dd92588807451cfbaf5800c4ae5e authored by Jochen Knaus on 24 April 2010, 00:00:00 UTC, committed by Gabor Csardi on 24 April 2010, 00:00:00 UTC
version 1.84
1 parent 0966757
  • Files
  • Changes
  • 55869cd
  • /
  • R
  • /
  • socketRequest.R
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • revision
  • directory
  • content
revision badge
swh:1:rev:97a6960daa89dd92588807451cfbaf5800c4ae5e
directory badge
swh:1:dir:6cfc417cbefe106a504a52f3f77021d8792f25b7
content badge
swh:1:cnt:29596370c933094a25ec192eb82939519cfa887f

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • revision
  • directory
  • content
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
socketRequest.R
#*****************************************************************************
# Functions for handling the connection to the controlling webserver.
#
# Base socketrequest follows code from post on R-help:
# http://tolstoy.newcastle.edu.au/R/devel/06/07/6196.html
#
# PARAMETER: Array|List Arguments (all Entries must be in format "name=val")
# RETURN:    Array result from webserver
# THROWS:    Exception Connection Error
#*****************************************************************************
connectWebserver <- function( call.args ) {
  host <- "www.imbi.uni-freiburg.de"
  path <- "/bib/bib.pl"

  # Parameters for the call.
  dat  <- paste( call.args, collapse="&", sep="" )

  len <- length( strsplit(dat,"")[[1]] )

  request <- paste( "POST ", path, " HTTP/1.0\nHost: ", host,
                    "\nReferer:\n",
                    "Content-type: application/x-www-form-urlencoded\n",
                    "Content-length: ", len,
                    "\nConnection: Keep-Alive\n\n", dat, sep="" )

  sock <- NULL      # Needed in catch-Block for disconnect
  readSock <- ""

  # Connect. Catch exceptions regarding to connection errors.
  exception <- try( {
         sock <- socketConnection( host=host, port=80,
                                   server=FALSE, blocking=TRUE )
  
         write( request, sock )
         socketSelect( list( sock ) )
         readSock <- readLines( sock )
         close( sock )
       }, silent=FALSE )

  if( inherits( exception, "try-error" ) ) {
    cat( "Error connecting to: ", host, path, dat, "\n" )

    # If socket exists, close it.
    if( sock != NULL ) close( sock )

    stop()
  }

  return( readSock )
}

##connectWebserver( c( "kat=ben", "cmd=list", "usr=jo", "usr_sel=JO" ) )
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API