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

  • 7221cdb
  • /
  • 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.

  • content
  • directory
content badge
swh:1:cnt:29596370c933094a25ec192eb82939519cfa887f
directory badge
swh:1:dir:7221cdb1f18e25116294db7c032e00e3ee864ef2

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.

  • content
  • directory
(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" ) )

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